Im doing an application n c# and using Ms Access 2003. i want to check whether a product id already exist in the database. Below is part of my code
string sql;
OleDbCommand cmd;
OleDbDataReader rdr;
mDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" + Path.Combine(Application.StartupPath, "..\\..\\Company.mdb");
mDB.Open();
sql = "Select COUNT (*) ProductID FROM Product";
cmd = new OleDbCommand(sql, mDB);
rdr = cmd.ExecuteReader();
if (txtProductID.Text == (string)rdr["ProductID"] )
{
MessageBox.Show("ID exixst");
}
else
{
return;
}