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 nume =' " + this.textBox1.Text+"' and parola ='"+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); }
}

VulpesRank #55 · 29.2K reputationPosted Mar 11, 2014, 9:15 AM EDT
If that's the case, then don't surround them with single quotes in your Select command.
raluca mindrut8 reputationPosted Mar 11, 2014, 9:32 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 11, 2014, 10:22 AM EDT
If you're getting a count of 0 but are expecting it to be 1, you need to watch out for mis-matches due to leading/trailing spaces or differences in capitalization.