Troubleshooting - QODBC Record Set Issue
Problem Description:
I am using the below code. It is returning records & giving me the correct result. But If I change the query from "SELECT Name FROM customer" to "SELECT * FROM customer," it does not return any records & giving me the incorrect result. I am getting the below error:
[QODBC] Internal error 440: BOF or EOF is True, or the current record has been deleted. The requested operation requires a current record.
Public Sub example select() Const adOpenStatic = 3 Const adLockOptimistic = 3 Dim oConnection Dim oRecordset Dim sMsg Dim sConnectString Dim sSQL sConnectString = "Driver={QODBC Driver for QuickBooks};DFQ=C:\QuickBooks\Maintenance.qbw;OpenMode=F;OLE DB Services=-2;" sSQL = "SELECT Name FROM customer" Set oConnection = CreateObject("ADODB.Connection") Set oRecordset = CreateObject("ADODB.Recordset") oConnection.Open sConnectString oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic sMsg = "**********************" & Chr(100) Do While (Not oRecordset.EOF) sMsg = sMsg & oRecordset.Fields("Name") & Chr(100) oRecordset.MoveNext Loop sMsg = sMsg & "**********************" MsgBox sMsg oRecordset.Close Set oRecordset = Nothing oConnection.Close Set oConnection = Nothing End Sub
Solution:
To resolve the issue, you need to add the below line in your connection string.
OptimizerAllowDirtyReads=N
For Example:
sConnectString = "Driver={QODBC Driver for QuickBooks};DFQ=C:\QuickBooks\Maintenance.qbw;OpenMode=F;OLE DB Services=-2;OptimizerAllowDirtyReads=N"
After changing this, you can get the correct result.
|