为什么我不断收到 SQL 语法错误:
未找到预期的词法元素:=)
以下是我的代码:我似乎找不到语法错误在哪里
Dim oConnection
Dim oRecordset
Dim sMsg
Dim sConnectString
Dim sSQL
customer = Forms.InvoiceForm.customerName
account = Forms.InvoiceForm.accountName
term = Forms.InvoiceForm.termName
names = Forms.InvoiceForm.nameText
addresses = Forms.InvoiceForm.addressText
city = Forms.InvoiceForm.cityText
state = Forms.InvoiceForm.stateText
postal = Forms.InvoiceForm.postalText
country = Forms.InvoiceForm.countryText
transDate = Forms.InvoiceForm.transactionText
dueDate = Forms.InvoiceForm.dueText
shipDate = Forms.InvoiceForm.shipText
tax = Forms.InvoiceForm.taxState
taxCode = Forms.InvoiceForm.taxCode
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 ('" & customer & "', '" & account & "', #9/23/2020#, '1','" & names & "', '" & addresses & "', '" & city & "', '" & state & "', '" & postal & "', 'USA',0, '" & term & "', #10/31/2020# , #10/01/2020# , '" & tax & "','hello', 0,'" & taxCode & "')"
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
这个查询的硬编码版本没有问题
INSERT INTO InvoiceLine (InvoiceLineItemRefListID, InvoiceLineDesc, InvoiceLineRate, InvoiceLineAmount, InvoiceLineSalesTaxCodeRefListID, FQSaveToCache) VALUES ('80002436-1519061496', 'Building permit 1', 1.00000, 1.00, '80000001-1478562826', 1)
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', #9/23/2020#, '1', 'Brad Lamb', '1921 Appleseed Lane', 'Bayshore', 'CA', '94326', 'USA', 0, '80000002-1478562832', #10/31/2020#, #10/01/2020#, '8000295C-1541711590', 'Memo Test', 0, '80000001-1478562826')