raluca mindrut

raluca mindrut

  • NA
  • 8
  • 3.8k

c# database login

Mar 11 2014 1:40 PM
Hi, I made this login form and even if the username and pass are correct, my program still show "NO". Can you tell me where I do wrong?
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); }
}

Answers (2)