I have a problem with a huge project that I am working on. I never had this problem before but it started occurring today. Any fixes?
error: System.Data.SqlClient.SqlException: 'The data types text and nvarchar are incompatible in the equal to operator.'
I don't understand what It means. I don't want to have an sql injection so I am using parameters.. But it still gives errors.
Please ask me if you need me to describe something... This is like my 5th post.
using (SqlCommand StrQuer = new SqlCommand("SELECT * FROM login WHERE username=@userid AND password=@password", connection))
{
StrQuer.Parameters.AddWithValue("@userid", username.Text.ToLower().Trim());
StrQuer.Parameters.AddWithValue("@password", obf.Obfuscate(password.Text).ToString());
SqlDataReader dr = StrQuer.ExecuteReader();
if (dr.HasRows)
{
Properties.Settings.Default.username = username.Text.ToLower();
Properties.Settings.Default.username = obf.Obfuscate(password.Text);
RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\howcoolitisX");
key.SetValue("username", username.Text.ToLower());
key.SetValue("password", obf.Obfuscate(password.Text));
key.Close();
Form executor = new Loader();
executor.Show();
this.Hide();
}
}