Data type mismatch in criteria expression

大憨熊 提交于 2019-12-02 09:36:50

cus_ID is probaly a numeric data type, but you try to query it with a string: (cus_ID = 'thevalue').

Just remove the enclosing ': (cus_ID = thevalue)

or better, use a parameterized query to prevent sql-injection.

I would recommend the following:

 Using cmd As New OleDbCommand("SELECT * FROM table1 WHERE cus_ID = @ID", con)
    cmd.Parameters.AddWithValue("@ID", txt_ID.Text)

    dr = cmd.ExecuteReader()

    While dr.Read()
      rtb_Address.Text = dr("cus_Addr").ToString
      txt_Name.Text = dr("cus_Name").ToString
    End While

 End Using
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!