|
-
Mar 18th, 2007, 08:02 AM
#1
Thread Starter
Junior Member
[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
-
Mar 19th, 2007, 06:26 AM
#2
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.
-
Mar 19th, 2007, 07:47 AM
#3
Thread Starter
Junior Member
Re: How to get info from database into vb
how do i change the ADOConnectionObjectName , what will i write there unsted of ADOConnectionObjectName??
-
Mar 19th, 2007, 08:21 AM
#4
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.
-
Mar 19th, 2007, 08:25 AM
#5
Thread Starter
Junior Member
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
-
Mar 19th, 2007, 09:12 AM
#6
Re: How to get info from database into vb
Then, cn is your connection object name.
-
Mar 19th, 2007, 10:20 AM
#7
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|