Private Sub del_Click()
Dim tmpid As String
If Adodc1.Recordset.EOF = True Then
MsgBox "請選擇記錄"
Exit Sub
End If
tmpid = Adodc2.Recordset.Fields(0)
MsgBox tmpid
If MsgBox("你是否真的要刪除當前記錄嗎", vbYesNo, "確認") = vbYes Then
cs.Execute "delete * from user_pn where PN001=tmpid"End IfEnd Sub
我是想刪除datagrid1控件中查詢得到的記錄。
運行行提求cs.Execute "delete * from user_pn where PN001=tmpid"句中“*”號邊的語句錯誤。
Dim tmpid As String
If Adodc1.Recordset.EOF = True Then
MsgBox "請選擇記錄"
Exit Sub
End If
tmpid = Adodc2.Recordset.Fields(0)
MsgBox tmpid
If MsgBox("你是否真的要刪除當前記錄嗎", vbYesNo, "確認") = vbYes Then
cs.Execute "delete * from user_pn where PN001=tmpid"End IfEnd Sub
我是想刪除datagrid1控件中查詢得到的記錄。
運行行提求cs.Execute "delete * from user_pn where PN001=tmpid"句中“*”號邊的語句錯誤。
"delete * from user_pn where PN001='"&tmpid&"'"
delete 语句不需要*。变量要用&符号连接才会起作用
明显的语法错误,只有Select 中才有*的概念
delete from table where 条件