Thursday, 2 July 2015

The data types ntext and varchar are incompatible in the equal to operator

I got an error message from the following sentense.
As far as I studied, this error occured becuase I compared Nvarchar and text. It is not incompatible.

 Dim vSqlStr As String = "SELECT * FROM HRSUSERS WHERE HRSUSERNAME = '" & Me.txtUsername.Text & "' AND HRSPASSWORD = '" & Me.txtPassword.Text & "'"

After I have changed to
Dim vSqlStr As String = "SELECT * FROM HRSUSERS WHERE HRSUSERNAME LIKE '" & Me.txtUsername.Text & "' AND HRSPASSWORD LIKE'" & Me.txtPassword.Text & "'"

It works. :)