Knowledgebase: TroubleShooting
[QODBC-Desktop] Using ADODC and ADODB with QODBC
Posted by Jack - QODBC Support on 06 July 2016 02:13 PM

Using ADODC and ADODB with QODBC

Download Sample


Open VB6, you can find it via Windows Start->All Programs->Microsoft Visual Studio 6.0 :

Create New Standard EXE project.

Then Add "Command Button" by double click on command button Icon. Command button will be added rename it to Get Customer via ADODB:


Double click on Command Button & add below code in the command button click event:

Private Sub Command1_Click()

Dim oConnection As ADODB.Connection
Dim oRecordset As ADODB.Recordset
Dim sMsg As String
Dim sConnectString As String
Dim sSQL As String

sConnectString = "DSN=QuickBooks Data;OLE DB Services=-2;"
sSQL = "SELECT top 10 Name FROM Customer"
Set oConnection = New ADODB.Connection
Set oRecordset = New ADODB.Recordset
oConnection.Open sConnectString
oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic
sMsg = "**********************" & Chr(10)
Do While (Not oRecordset.EOF)
sMsg = sMsg & oRecordset.Fields("Name") & Chr(10)
sMsg = sMsg & "**********************" & Chr(10)
MsgBox sMsg

Set oRecordset = Nothing
Set oConnection = Nothing

End Sub

Now execute the code from Run >> Start With Full Compile

Double click on Get Customer via ADODB which will get top 10 customer's name & display it in msg box:


Now we will add ADODC control in the same project which we created in above ADODB example.

Now we will configure ADODC control by right click on ADODC control & click on ADODC Properties:

From the General tab, Select ODBC Data Source QuickBooks Data.

Navigate to RecordSource tab, Select Command type to 2 - adCmdTable & table name Customer and click OK.

Now we will add three text box which will show Customer table data through ADODC control.

Now we will configure text boxes for display data from ADODC control. Choose DataSource Adodc1 (i.e. ADODC Control name) & DataField FullName (i.e. Field name which you want to show):

Same way we will configure other two textboxes with Phone & Email field.

Now execute the code from Run >> Start With Full Compile

By clicking on "Next" button, next customer data will be displayed.


(0 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please complete the captcha below (we use this to prevent automated submissions).