[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
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.
Re: How to get info from database into vb
how do i change the ADOConnectionObjectName , what will i write there unsted of ADOConnectionObjectName??
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.
Re: How to get info from database into vb
vb Code:
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\sparadespelare.mdb"
cn.Open
Re: How to get info from database into vb
Then, cn is your connection object name.
Re: How to get info from database into vb
Thank you so much, is working:)
woho