SQL 문에서 오류를 찾는 데 도움이 필요합니다. 나는 여러 가지 일을 시도해 왔지만 아무 것도 효과가없는 것 같습니까? 이것은 내가SQL 오류 액세스 2010 VBA 업데이트 명령
Run-time error '3075':
Syntax error (missing operator) in query expression '([description] = Manufacturing and Delivery Schedule AND [pr_num] = 83)'.
를 나타나는 오류 메시지입니다 이건 내 코드입니다 : 사전에 어떤 도움
이Private Sub Command6_Click()
' ===================================================
' Receives the selected item in the combo box
' ===================================================
' Open the Database connection
Dim data_base As Database
Set data_base = CurrentDb
' Grab description and pr number from the form
Dim desc As string
dim pr_number as long
desc = Combo4.Value
pr_number = Text8.Value
' Build the query
Dim query As String
query = "UPDATE VDR_Table " & _
"SET [received] = [p1] " & _
"WHERE ([description] = " & desc & _
" AND [pr_num] = " & pr_number & ");"
Dim rec_set As DAO.Recordset
Set rec_set = data_base.OpenRecordset(query)
' Build the QueryDef
Set qd = data_base.CreateQueryDef("")
qd.SQL = query
' Execute query
qd.Parameters("p1").Value = true
qd.Execute
' Close nad null record set
rec_set.close
set rec_set = nothing
' Close the connection to the database
data_base.Close
' Prompt the user success
MsgBox "Item has been received"
End Sub
감사합니다!
DAO, 매개 변수 및 긴 문자열에 어려움이 있습니다. SQL 주입은 MS Access에서 꽤 동일하지 않습니다. 가능한 한 작은 따옴표를 desc에서 빠져 나오려고합니다. – Fionnuala
따옴표를 이스케이프하지만 매개 변수를 사용하면 문제가 해결되지 않습니까? – ryanulit
DAO와 255보다 긴 문자열을 가진 매개 변수를 사용할 수 없습니다. – Fionnuala