I have a small method that basically checks if a check box is checked or un-check when the Page loads.
I do however get the above error message, stating that it cannot find the table ‘tblProducts’ which I find strange as the table does exist in the database.
Why do I get this OleDbException?
this is what I have done.
public void checkedOrNot(CheckBox chk, string column, string table)
{
string codevalue;
Session["exeFilePath"] = Request.CurrentExecutionFilePath;
using (OleDbConnection myOLEDBConn = new OleDbConnection(ConfigurationManager.AppSettings["conn"]))
{
bool value = false;
codevalue = Request.QueryString["code"];
myOLEDBConn.Open();
OleDbCommand cmd = myOLEDBConn.CreateCommand();
cmd.CommandText = "SELECT ['" + column + "'] FROM ['" + table + "'] WHERE [CODE] = '" + codevalue + "'";
OleDbDataReader dbReader = cmd.ExecuteReader();
if (dbReader.Read())
{
value = (bool)dbReader["" + column + ""];
}
if (value == true)
{
chk.Checked = true;
}
else
{
chk.Checked = false;
}
}
}
checkedOrNot(chkPreview, "PreviewLibraryChecked", "tblProducts");
regards
Replace the line
with this one