SQLite错误提供给命令vb.net的参数不足

时间:2013-11-28 09:19:58

标签: vb.net sqlite

salam我得到这个错误(SQLite错误提供给命令的参数不足)在这段代码中请帮帮我

 If CheckBox1.Checked Then
            Dim query1 As String = "Select payid FROM SS_paymon WHERE paytid = '" & idtext.Text & "'"

            Dim command As New SQLiteCommand(query1, objConn)
            'Dim param As New SQLiteParameter()
            Dim haha As DataTable = New DataTable()
            Dim adapter As New SQLiteDataAdapter(command)
            adapter.Fill(haha)
            If haha.Rows.Count = 0 Then
                Dim SQLstr3 As String = "INSERT INTO SS_paymon (payprice, paybuyer, paydate,paytid) VALUES(@payprice, @paybuyer, @paydate,@paytid)"
                Dim cmdb3 As New SQLiteCommand(SQLstr2, objConn)
                cmdb3.Parameters.AddWithValue("@payprice", TextBox5.Text)
                cmdb3.Parameters.AddWithValue("@paybuyer", bid.Text)
                cmdb3.Parameters.AddWithValue("@paydate", TextBox4.Text)
                cmdb3.Parameters.AddWithValue("@paytid", idtext.Text)
                cmdb3.ExecuteNonQuery()
                cmdb3.Dispose()
            Else
                Dim SQLstr3 As String = "UPDATE SS_paymon SET payprice=@payprice, paybuyer=@paybuyer, paydate=@paydate WHERE paytid=@paydate"
                Dim cmd3 As New SQLiteCommand(SQLstr2, objConn)
                cmd3.Parameters.AddWithValue("@payprice", TextBox5.Text)
                cmd3.Parameters.AddWithValue("@paybuyer", bid.Text)
                cmd3.Parameters.AddWithValue("@paydate", TextBox4.Text)
                cmd3.Parameters.AddWithValue("@paytid", idtext.Text)
                cmd3.ExecuteNonQuery()
                cmd3.Dispose()
            End If
            adapter.Dispose()
        Else
            Dim query1 As String = "Select payid FROM SS_paymon WHERE paytid = '" & idtext.Text & "'"
            Dim command As New SQLiteCommand(query1, objConn)
            Dim haha As DataTable = New DataTable()
            Dim adapter As New SQLiteDataAdapter(command)
            adapter.Fill(haha)
            If haha.Rows.Count <> 0 Then
                Dim SQLstr3 As String = "DELETE FROM SS_paymon where paytid=@paytid"
                Dim cmdx1 As New SQLiteCommand(SQLstr2, objConn)
                cmdx1.Parameters.AddWithValue("@paytid", idtext.Text)
                cmdx1.ExecuteNonQuery()
                cmdx1.Dispose()
            End If

        End If

我在所有ExecuteNonQuery()中都收到此错误。

我搜索有什么问题,但我找不到任何代码

这是一个更新按钮; 如果选中复选框(PAID),则应检查付款表中是否有任何记录 如果它有更新的东西,否则添加新的 如果检查未选中,则应检查是否存在应删除的付款记录。

1 个答案:

答案 0 :(得分:1)

您在此代码中设置的字符串变量名为SQLstr3 您在命令中实际使用的字符串变量名为SQLstr2

WHERE paytid=@paydate错了。