473,378 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Code ok in DEBUG fails in Release

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

Nov 2 '05 #1
2 1779
Is this the only things that change ? If you don't run the debug and the
release code on the same datasource, it could be just that the line is
missing from the Params table...

--
Patrice

"John Beschler" <Jo**********@discussions.microsoft.com> a écrit dans le
message de news:F0**********************************@microsof t.com...
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

Nov 2 '05 #2
Patrice,

Thanks for your response. I think you're right. I was looking at two
different data sources based upon whether it was production or testing.
However, it should have been the other way aroound because the datasource for
debug did not have the record, yet teh datasource for release did.

I think what happened is I got my command line params confused in VS.Net.
In 6.0 there was no difference between debug and release and I did not
realize there was a seperate command line configuration for debug/release in
VS.Net.
Always learning.

Thanks again.

"Patrice" wrote:
Is this the only things that change ? If you don't run the debug and the
release code on the same datasource, it could be just that the line is
missing from the Params table...

--
Patrice

"John Beschler" <Jo**********@discussions.microsoft.com> a écrit dans le
message de news:F0**********************************@microsof t.com...
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


Nov 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: aaj | last post by:
Hi all I have written a small app on my machine that I have passed on to a colleague for testing. The problem is, as soon as he steps through in debug mode and reaches try { conn.Open();...
6
by: ss | last post by:
Hi I built an exe in console debug mode & Release mode . The console debug mode -exe works fine ...but the release mode EXE starts well but fails mid way . The exe is being started as a...
1
by: Carlos Lozano | last post by:
Hi, I have a multithreading application that reads and writes to com ports. The debug version works with no problems, but the release version don't. They are the same code, the difference is...
21
by: Chris Durkin | last post by:
I've got an ASP.NET website on my local box, set to compile to bin\Debug and bin\Release in debug and release modes. Both directories are populated with dlls, as the solution has been compiled in...
19
by: Alan Silver | last post by:
Hello, I have been developing ASP.NET with a text editor so far (better way to learn initially), and have now been trying Visual Web Developer. I want to create a project for an existing site...
2
by: John Beschler | last post by:
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...
10
by: musosdev | last post by:
I've got a function that needs to work slightly differently on the development server from the production server, but of course I don't want to be changing code just before compiling a release...
3
by: O.B. | last post by:
In .NET 2005, I have a C# GUI project that is dependent on a C# DLL project. When I compile the GUI project in Release mode, it copies the "debug" version of the DLL into the bin directory of the...
3
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.