我正在嘗試創建以下SQL INSERT INTO語句,但出現語法錯誤。任何建議?:編譯錯誤:語法錯誤 - MS INSERT INTO語句上的MS ACCESS 2007
SQL = "
INSERT INTO AptRent
(BuildingID,
RentAmountID,
InitialRentDueDate,
TenantID,
AptNoID,
MoveInDate,
MoveOutDate,
DateAdded,
SecurityAmount,
SecurityPaid,
NoDaysLate,
LateAmount)
VALUES
(" & Me.cbSelectBuildingForRental & ","
& Me.cbCreateRentalRentAmount & ","
& Me.tbCreateRentalRDD & ","
& Me.cbSelectTenantForRental & ", '"
& Me.cbSelectAptNoforRental & "' ,"
& Me.tbCreateRentalMID & ","
& Me.tbCreateRentalMOD & ","
& Now() & ","
& Me.tbSecurityAmnt & ","
& Me.ckSecurityPd & ","
& Me.tbNoDaysLate & ","
& Me.tbLatePmnt & ")"
表AptRent具有以下數據類型:
BuildingRentID:自動編號
BuildingID:數量(Me.cbSelectBuildingForRental)
RentAmountID:號碼(Me.cbCreateRentalRentAmount)
InitialRentDueDate:日期/時間(Me.tbCreateRentalRDD)
TenantID:號碼(Me.cbSelectTenantForRental)
AptNoID:Text(Me.cbSelectAptNoforRental)
MoveInDate:日期/時間(Me.tbCreateRentalMID)
MoveOutDate:日期/時間(Me.tbCreateRentalMOD)
DateAdded:日期/時間( Now())
SecurityAmount:貨幣(Me.tbSecurityAmnt)
SecurityPaid:是/否(Me.ckSecurityPd)
NoDaysLate:號碼(Me.tbNoDaysLate)
LateAnount:貨幣(Me.tbLatePmnt)
實際上,因爲他使用了ms-access。他會想用#而不是'。 –
@DanielCook:我認爲單引號可以工作*當值是ISO格式時*,我在我的假設中說過。否則,你是正確的。 –
我認爲這取決於他用什麼「引擎」來運行這個語句。如果它是DAO或ODBC鏈接表(這也是DAO),那麼他將需要散列符號。我相信ADO也需要散列符號,儘管我並不完全確定這一點。無論如何,他肯定確實需要圍繞日期值。 – HK1