在vb中一起执行多个命令

时间:2012-07-22 16:06:12

标签: ms-access vb6

我正在开发一个vb项目。在这里我需要将一些记录保存到一个表并在一个事件中更新另一个表中的一些记录或单击..我这样做。

       Conn.Execute "insert into DailyStock(serial,category,model,datee,opnstock,supply,phystk,totalsale,ssale,nsale,totalstock)values(" & txtserial.Text & ",'" & CboCategory.Text & "','" & CboModel.Text & "','" & DTPicker1 & "'," & txtopnstock.Text & "," & txtsupply.Text & "," & txtphystk.Text & "," & txttsale.Text & "," & txtssale.Text & "," & txtnsale.Text & "," & txtstock.Text & ") ; update Menu set phystk=" & txtstock & " where ItemName='" & CboModel & "'"
       MsgBox ("Data  Saved Successfully")

但它给出的错误是“在sql语句后找到的字符”..我没有得到我出错的地方..请帮帮我

1 个答案:

答案 0 :(得分:2)

您只能在MS Access中一次运行一条语句。 “;”之后的一切是在sql语句之后找到的字符。

Conn.Execute "insert into DailyStock(serial,category,model,datee,"_
 & "opnstock,supply,phystk,totalsale,ssale,nsale,totalstock)values(" _
 & txtserial.Text & ",'" & CboCategory.Text & "','" _
 & CboModel.Text & "','" & DTPicker1 & "'," & txtopnstock.Text _
 & "," & txtsupply.Text & "," & txtphystk.Text & "," & txttsale.Text & "," _
 & txtssale.Text & "," & txtnsale.Text & "," & txtstock.Text & ") "

Conn.Execute "update Menu set phystk=" & txtstock _
 & " where ItemName='" & CboModel & "'"