Results 1 to 7 of 7

Thread: [RESOLVED] How to get info from database into vb

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    22

    Resolved [RESOLVED] How to get info from database into vb

    I have connected my database "sparadespelare.mdb" with the table "tbl_sparadespelare" i have 3 colums (fields) in the tabel, and when i click on a button i want to show a new form, i have don that with from.show and then i want to have a listbox there i could click on one of the rows that the app have loaded from the database(in the listbox it should list field1), and when the user click on it it will load data from the other fields on the same row inte variables, how can i do that, i want to use the ADODB connection.
    thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to get info from database into vb

    Code:
    Dim sSQL As String
    sSQL = "SELECT field2, field3 FROM table WHERE field1 = '" & List1.Text & "' "
    Set rs = New ADODB.Recordset
    rs.Open sSQL, ADOConnectionObjectName
    Change rs to your recordset object name and ADOConnectionObjectName to your connection object name.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    22

    Re: How to get info from database into vb

    how do i change the ADOConnectionObjectName , what will i write there unsted of ADOConnectionObjectName??

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to get info from database into vb

    The name of your connection object.

    Post the code you use to connect to you database.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    22

    Re: How to get info from database into vb

    vb Code:
    1. Set cn = New ADODB.Connection
    2.     cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    3.       "Data Source=" & App.Path & "\sparadespelare.mdb"
    4.     cn.Open

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to get info from database into vb

    Then, cn is your connection object name.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    22

    Resolved Re: How to get info from database into vb

    Thank you so much, is working
    woho

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width