ms访问数据库上的数据类型不匹配

时间:2016-08-04 16:54:09

标签: vb.net ms-access

我的程序有问题。它说"附加信息:标准表达式中的数据类型不匹配。"错误是扔到rs.Fill(dt)这里是我的代码

con.Open()

        Dim dt As New DataTable("tbl_Stock")
        Dim rs As New OleDb.OleDbDataAdapter("Select * from [tbl_Stocks] WHERE [Product] ='" & lbPro.Text & "' AND [Batch ID] = '" & txtID.Text & "'", con)
        Dim ve As String
        rs.Fill(dt)


        ve = CStr(dt.Rows.Count)
        rs.Dispose()
        con.Close()

1 个答案:

答案 0 :(得分:0)

很可能,批次ID 是数字,因此没有引号:

Dim rs As New OleDb.OleDbDataAdapter("Select * from [tbl_Stocks] WHERE [Product] ='" & lbPro.Text & "' AND [Batch ID] = " & txtID.Text & "", con)