查询和目标文件夹错误的数量

时间:2017-03-02 08:53:18

标签: database vb.net ms-access vb.net-2010

我正在尝试使用SQL语句添加新事务。

数据库: Ms Access

行代码:

sqL = "INSERT INTO TableTransactions VALUES('"
        & transno.Text & "','" & cmbmonth.Text & "','" & cmbdate.Text
        & "','" & txtCash.Text & "','" & txtLand.Text & "','"
        & txtADFee.Text & "','" & txtBuilding.Text & "','"
        & txtEquipments.Text & "','" & txtAReceivables.Text
        & "','" & txtAPayable.Text & "','" & txtNPayable.Text
        & "','" & txtSPayable.Text & "','" & txtTPayable.Text
        & "','" & txtCapital.Text & "','" & txtExpenses.Text
        & "','" & txtRevenue.Text & "','" & txtDrawings.Text & "')"

错误:

  

查询和目标文件夹错误数。

1 个答案:

答案 0 :(得分:0)

您必须指定字段的顺序:

sqL = "INSERT INTO TableTransactions (FieldNo, FieldMonth, FieldDate, ... etc.) VALUES('"
    & transno.Text & "','" & cmbmonth.Text & "','" & cmbdate.Text
    & "','" & txtCash.Text & "','" & txtLand.Text & "','"
    & txtADFee.Text & "','" & txtBuilding.Text & "','"
    & txtEquipments.Text & "','" & txtAReceivables.Text
    & "','" & txtAPayable.Text & "','" & txtNPayable.Text
    & "','" & txtSPayable.Text & "','" & txtTPayable.Text
    & "','" & txtCapital.Text & "','" & txtExpenses.Text
    & "','" & txtRevenue.Text & "','" & txtDrawings.Text & "')"

那就是说,请阅读如何使用参数来避免串联模糊并提高安全性。