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

ADODB with QODBC

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

Create a New Standard EXE project.

Then Add "Command Button" by double clicking on the command button Icon. A command button will be added. Rename it to Get Customer via ADODB:

 

Double click on Command Button & add the 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)
oRecordset.MoveNext
Loop
sMsg = sMsg & "**********************" & Chr(10)
MsgBox sMsg

oRecordset.Close
Set oRecordset = Nothing
oConnection.Close
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 the top 10 customer's name & display it in msg box:

ADODC with QODBC

Now we will add ADODC control in the same project we created in the 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 the RecordSource tab, Select Command type to 2 - adCmdTable & table name Customer, and click OK.

Now we will add three text boxes showing Customer table data through ADODC control.

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

Similarly, we will configure the other two textboxes with the Phone & Email fields.

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

The following customer data will be displayed by clicking on the "Next" button.

 

(0 vote(s))
Helpful
Not helpful

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