0

我正在做一个 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 语句后找到的字符”.. 我没有找到我出错的地方.. 请帮助我

4

1 回答 1

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 & "'"
于 2012-07-22T16:08:28.460 回答