Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 数据库DoCmd.RunSql中的SQL错误_Mysql_Vb.net - Fatal编程技术网

Mysql 数据库DoCmd.RunSql中的SQL错误

Mysql 数据库DoCmd.RunSql中的SQL错误,mysql,vb.net,Mysql,Vb.net,当我在doCmd.RunSql(StringSQL)上运行insert to表时,上面的错误将显示在上面指示的位置因此,不确定我做错了什么我猜Visual Basic标记可能是个好主意,但在insere-into语句中仍然存在运行时错误3134语法错误哪个查询给出了errordebug.print stringSQL-与“替换”不太符,我怀疑我在运行实际表单时,以及在结束时没有输入任何信息时,发现了错误。如果我输入了新项目,那么它会正常工作。但若我在不关闭表单的情况下继续输入信息,那个么只有我输

当我在doCmd.RunSql(StringSQL)上运行insert to表时,上面的错误将显示在上面指示的位置因此,不确定我做错了什么

我猜Visual Basic标记可能是个好主意,但在insere-into语句中仍然存在运行时错误3134语法错误哪个查询给出了errordebug.print stringSQL-与“替换”不太符,我怀疑我在运行实际表单时,以及在结束时没有输入任何信息时,发现了错误。如果我输入了新项目,那么它会正常工作。但若我在不关闭表单的情况下继续输入信息,那个么只有我输入的第一项被插入到表中。看起来我需要一个类似“输入另一个是/否”的问题,如果是,则应循环回开始并允许另一个输入,如果否,则结束并关闭表单。
Private Sub Form_Close()

    Dim sSQL, stringSQL As String
    Dim rst As DAO.Recordset

    sSQL = "SELECT BarCode, [Goods Name] FROM tblInventory WHERE BarCode='" & Me.ID & "'"
    Set rst = CurrentDb.OpenRecordset(sSQL)
    If rst.EOF Then
        stringSQL = "INSERT INTO tblInventory(BarCode,[Goods Name],Unit,[Unit Price],[Initial Stock],[Current Stock],[Exit Item]) values('" & Me.ID & "','" & Me.Description & "','" & Me.Unit & "'," & Replace(Format(Me.Price, "0.00"), ",", ".") & "," & Me.Amount & "," & Me.Amount & ",0)"
        DoCmd.SetWarnings False
        DoCmd.RunSQL (stringSQL) /this is where it is erroring out/
        DoCmd.SetWarnings True
    Else
        stringSQL = "UPDATE tblInventory SET [Current Stock]=[Current Stock]+" & Me.Amount & " WHERE BarCode='" & Me.ID & "'"
        DoCmd.SetWarnings False
        DoCmd.RunSQL (stringSQL)
        DoCmd.SetWarnings True
    End If
    rst.Close
End Sub

Private Sub ID_AfterUpdate()
    Dim sSQL As String
    Dim rst As DAO.Recordset

    sSQL = "SELECT BarCode, [Goods Name], Unit, [Unit Price] FROM tblInventory WHERE BarCode='" & Me.ID & "'"
    Set rst = CurrentDb.OpenRecordset(sSQL)
    If rst.EOF Then
        MsgBox "New Parts"
        Me.Description.SetFocus
    Else
        Me.Description = rst(1).Value
        Me.Unit = rst(2).Value
        Me.Price = rst(3).Value
        Me.Amount.SetFocus
    End If
    rst.Close
End Sub