G
Guest
I have a c# function that runs fine in VS.Net when in debug mode; however,
when I switch to Relase mode or compile the app, the function fails with
"object refernce not set".
Here is the whole function:
private void GetETCStatus()
{
oConn.Open();
szSQL = "SELECT ParamValue FROM Params WHERE Param =
'ETCsAvailable'";
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
object o = cmd.ExecuteScalar();
szTemp = o.ToString().ToUpper();
if (szTemp == "YES")
{
this.cmdETCs.Text = "&Disable ETCs";
bETCsAvailable = true;
}
else
{
this.cmdETCs.Text = "&Enable ETCs";
bETCsAvailable = false;
}
this.Refresh();
oConn.Close();
}
the line that fails is:
szTemp = o.ToString().ToUpper();
All I'm trying to do is retrieve one scalar value from the SQL database. I
don't need a dataset for this.
Can someone explain why it works in DEBUG and not in release? (Makes it very
difficult to troubleshoot.)
In lieu of that, can someone show me a better way to accomplish what I'm
trying to do here?
Thanks,
John
when I switch to Relase mode or compile the app, the function fails with
"object refernce not set".
Here is the whole function:
private void GetETCStatus()
{
oConn.Open();
szSQL = "SELECT ParamValue FROM Params WHERE Param =
'ETCsAvailable'";
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
object o = cmd.ExecuteScalar();
szTemp = o.ToString().ToUpper();
if (szTemp == "YES")
{
this.cmdETCs.Text = "&Disable ETCs";
bETCsAvailable = true;
}
else
{
this.cmdETCs.Text = "&Enable ETCs";
bETCsAvailable = false;
}
this.Refresh();
oConn.Close();
}
the line that fails is:
szTemp = o.ToString().ToUpper();
All I'm trying to do is retrieve one scalar value from the SQL database. I
don't need a dataset for this.
Can someone explain why it works in DEBUG and not in release? (Makes it very
difficult to troubleshoot.)
In lieu of that, can someone show me a better way to accomplish what I'm
trying to do here?
Thanks,
John