how can i retrieve the data from sql-server2005 from multiple tables in two combo-boxes in vb6.0 using programming code

30 pts.
Tags:
ComboBox
SQL Server 2005
VB 6.0
how can i retrieve the data from sql-server 2005 from multiple tables in two combo-boxes in vb6.0 using programming code

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is an example, using ADO and an ODBC data source to connect to the database:

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 "SELECT t1.field_y FROM table_1 t1 JOIN table_2 t2 ON t1.column_x = t2.column_x", adoConnection

' Populate the combo
Do Until adoRecordset.EOF
   Combo1.AddItem adoRecordset!field_y
    adoRecordset.MoveNext
Loop

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Narendar
    Please post the tables structure and which data you would like to be shown.
    0 pointsBadges:
    report
  • carlosdl
    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.
    69,175 pointsBadges:
    report
  • Rupalidhepe
    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?
    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following