here is the code
I am getting this error: "data type mismatch in criteria expression" Can you tell me why?
here's the code
try
{
string constring = @"Provider = Microsoft.ACE.OLEDB.12.0; Data source= bla.accdb;Persist Security Info=True;";
OleDbConnection conexiune = new OleDbConnection(constring);
OleDbCommand cmdDataBase = new OleDbCommand("Select * from Table1 where username =' " + this.textBox1.Text+"' and pass ='"+this.textBox2.Text+"';", conexiune);
OleDbDataReader myReader;
conexiune.Open();
myReader = cmdDataBase.ExecuteReader();
int count = 0;
while (myReader.Read())
{ count = count + 1; }
if (count == 1)
{
MessageBox.Show("FS");
}
else
{
MessageBox.Show("no");
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
Munesh SharmaPosted Mar 12, 2014, 3:06 AM
{
try
{
string str = "server = MUNESH\\SQL2008R2;Database=datastore;UID=sa;Password=123;";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("Select * from login where username = '" + this.textBox1.Text + "' and password = '" + this.textBox2.Text + "'", con);
SqlDataReader myreader;
con.Open();
myreader = cmd.ExecuteReader();
int count = 0;
while (myreader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Username and password correct");
}
else if (count > 1)
{
MessageBox.Show("Duplicate username and password");
}
else
MessageBox.Show(" username and password incorrect");
con.Close();
}
catch (Exception es)
{
MessageBox.Show(es.Message);
}
}
VulpesPosted Mar 11, 2014, 3:01 PM
Also, it's difficult to see how the username and password columns can be anything other than strings in the database which is the usual reason for this error.