Home
> IT Answers
> Development
> how can i retrieve the data from sql-server2005 from multiple tables in two combo-boxes in vb6.0 using programming code
Here is an example, using ADO and an ODBC data source to connect to the database:
<pre>
Dim adoConnection As ADODB.Connection
Dim adoRecordset As ADODB.Recordset
Dim connectString As String
'-Create a new connection --
Set adoConnection = New ADODB.Connection
'-Create a new recordset --
Set adoRecordset = New ADODB.Recordset
'-Build the connection string to use when we open the connection --
connectString = "Data Source=sql;Database=test;Uid=your_username; Pwd=your_password;"
adoConnection.Open connectString
adoRecordset.Open "<b>SELECT t1.field_y FROM table_1 t1 JOIN table_2 t2 ON t1.column_x = t2.column_x</b>", adoConnection
' Populate the combo
Do Until adoRecordset.EOF
<b>Combo1.AddItem adoRecordset!field_y</b>
adoRecordset.MoveNext
Loop</pre>
Last Wiki Answer Submitted: April 28, 2009 1:49 pm by carlosdl63,535 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
I have one table in oracle database as student having fields as roll,name,marks & i want to display student names in combo box using OLEDB connectivity. how can i do this?
Please post the tables structure and which data you would like to be shown.
There is no need to post the table structures; just adapt the above example to your needs.
Feel free to ask if you have any questions.
I have one table in oracle database as student having fields as roll,name,marks & i want to display student names in combo box using OLEDB connectivity. how can i do this?