Avatar billede bendixen Novice
27. februar 2003 - 11:44 Der er 2 kommentarer og
1 løsning

Udlæsning fra MSDE sql db.

Jeg skal hente nogle data ud, fra en bestemt række i en tabel, i en MSDE SQL database

Hvordan gør man det ?

Jo mere kode jo flere point !
Avatar billede jrl0469 Nybegynder
27. februar 2003 - 11:56 #1
Use a SqlDataAdapter object to load the data into a DataSet. Make a DataView based on the data you want to display. In this example, the data is in the Contacts table.
Set the DataView's AllowDelete, AllowEdit, and AllowNew properties to False. Then bind the DataView to the DataGrid control for display. The DataGrid will automatically prevent the user from deleting, editing, or adding values.


Private Const SELECT_STRING As String = _
    "SELECT * FROM Contacts ORDER BY LastName, FirstName"
Private Const CONNECT_STRING As String = _
    "Data Source=Bender\NETSDK;Initial " & _
        "Catalog=Contacts;User Id=sa"

' The DataSet that holds the data.
Private m_DataSet As DataSet

' A DataView to allow read-only access the data.
Private m_DataView As DataView

' Load the data.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    Dim data_adapter As SqlDataAdapter

    ' Create the SqlDataAdapter.
    data_adapter = New SqlDataAdapter(SELECT_STRING, _
        CONNECT_STRING)

    ' Map Table to Contacts.
    data_adapter.TableMappings.Add("Table", "Contacts")

    ' Fill the DataSet.
    m_DataSet = New DataSet()
    data_adapter.Fill(m_DataSet)

    ' Make a DataView for the data.
    m_DataView = New DataView(m_DataSet.Tables("Contacts"))
    m_DataView.AllowDelete = False
    m_DataView.AllowEdit = False
    m_DataView.AllowNew = False

    ' Bind the DataGrid control to the DataView.
    dgContacts.DataSource = m_DataView
End Sub
Avatar billede jrl0469 Nybegynder
27. februar 2003 - 11:57 #2
Avatar billede bendixen Novice
19. juli 2005 - 14:20 #3
nu skal dette ? vist lukkes
ikke fordi jeg har kunnet bruge dit svar
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester