I have a question according to this code. VisualStudio shows no errors or warnings but when I run it, the result is only the exceptionerror ("Something went wrong."). This is how I have always done it before but somehow always worked except for now. Am I missing a simple thing?
protected void Page_Load(object sender, EventArgs e)
{
// Connect
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\royva\documents\visual studio 2013\Projects\CookieMultiView\CookieMultiView\App_Data\Databank.mdb';Persist Security Info=True";
// Execute
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT * FROM teachers = ?";// + Request.QueryString["id"];
lbl.Text = "";
cmd.Parameters.AddWithValue("id",Request.QueryString["id"]);
// Read
try
{
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
lbl.Text = reader["teacherid"].ToString();
}
}
catch (Exception ex)
{
//lbl.Text = ex.StackTrace;
lbl.Text = "Something went wrong.";
}
finally
{
conn.Close();
}
lbl.Text = "Something went wrong.";and then put a break point onlbl.Text = ex.StackTrace;and step through it. Also you're adding a paramidbut it's not in your select querylbl.Text = "Something went wrong.";line and see what is the actual exception. As of now, it can be any of the hundred issues.