c# error
-
i have 2 connectionstring in c# and 2 connection with 2 different access database in this query i use only one access db and one connection string but when i run the program it appears an error that say that could not found file dbfile.accdb what is the problem ? public bool findrefyear( string refyear) { bool findyear = false; //create new new access connection to the database OleDbConnection connd = new OleDbConnection(connection2); //Set the access command string OleDbCommand Cmd = new OleDbCommand("SELECT ReferenceYear FROM Questionnaires_Table1 Where ReferenceYear = '" + refyear + "';", connd); try { connd.Open(); Cmd.ExecuteNonQuery(); connd.Close(); findyear = true; } catch (OleDbException e) { MessageBox.Show(e.Message.ToString()); } i call the above code with this code: ----------------------------------------- ...
if (txtdateref.Text != "" )
{bool find\_data = qhandler.findrefyear(txtdateref.Text); if (find\_data == false) { MessageBox.Show(" the record is not here ", "", MessageBoxButtons.OK); } else{ MessageBox.Show(" the record is here ", "", MessageBoxButtons.OK); }
}
zebra88 wrote:
what is the problem ?
Dunno. Does "error" mean that it throws an exception that the access database cannot be found? If yes, then there's an error in your connectionstring. If no, does "error" mean that it displays the message "the record is not here"? Further, a "select" statement is a query. One would use the
ExecuteReader
method to read the dataset.Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]