此查询是否未保存到正确的缓存中?

时间:2019-01-16 20:42:35

标签: sql vba ms-access qodbc

我想使用VBA SQL将在Microsoft Access中创建的发票插入QuickBooks中

以下是正在执行的SQL查询(buttonA)应该将invoiceLine保存在缓存(FQSaveToCache)中,但是似乎这样做了,但是当我对(buttonB)运行查询时,出现错误提示:

运行时错误'-2147467259(80004005)':

[QODBC]不支持-至少需要一个行记录。请在插入父/标题记录之前插入子/详细记录。有关更多详细信息,请访问:godbc.comilinks / 2953

还请注意,以下查询已正确执行,并且可以在Access Query Designer中使用。

按钮代码:

Option Compare Database


Private Sub buttonA_Click()

Const adOpenStatic = 3
Const adLockOptimistic = 3


Dim oConnection
Dim oRecordset
Dim sMsg
Dim sConnectString
Dim sSQL


items = Forms.InvoiceForm.itemName
description = Forms.InvoiceForm.description
rate = Forms.InvoiceForm.rate
amount = Forms.InvoiceForm.amount

sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"

sSQL = "INSERT INTO InvoiceLine (InvoiceLineItemRefListID, InvoiceLineDesc, InvoiceLineRate, InvoiceLineAmount, InvoiceLineSalesTaxCodeRefListID, FQSaveToCache) VALUES ('80002436-1519061496', 'Building permit 1', 1.00000, 1.00, '80000001-1478562826', 1)"


Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConnection.Open sConnectString
oConnection.Execute (sSQL)
sMsg = sMsg & "Invoice details were gathered!"
MsgBox sMsg

End Sub

buttonB代码:

Option Compare Database
Private Sub buttonB_Click()

Const adOpenStatic = 3
Const adLockOptimistic = 3


Dim oConnection
Dim oRecordset
Dim sMsg
Dim sConnectString
Dim sSQL


sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"



sSQL = "INSERT INTO Invoice (CustomerRefListID, ARAccountRefListID, TxnDate, RefNumber, BillAddressAddr1, BillAddressAddr2, BillAddressCity, BillAddressState, BillAddressPostalCode, BillAddressCountry, IsPending, TermsRefListID, DueDate, ShipDate, ItemSalesTaxRefListID, [Memo], IsToBePrinted, CustomerSalesTaxCodeRefListID)  VALUES ('800001F6-1482536280', '8000001E-1478562986', {d '2020-09-23'}, '1', 'Brad Lamb', '1921 Appleseed Lane', 'Bayshore', 'CA', '94326', 'USA', 0, '80000002-1478562832', {d '2020-10-31'}, {d '2020-10-01'}, '8000295C-1541711590', 'Memo Test', 0, '80000001-1478562826')"


Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConnection.Open sConnectString
oConnection.Execute (sSQL)
sMsg = sMsg & "Invoice was Sent to QuickBooks"
MsgBox sMsg


End Sub

buttonA是应该附加到其必要表以及使用FQSaveToCache保存在缓存中的子项。

所有这些,我不明白为什么会收到此错误。

0 个答案:

没有答案
相关问题