473,386 Members | 1,883 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,386 software developers and data experts.

sqlHelper exception handling

Hi,

Calling my method below how does my page caller display the exception since
the return type is int?

int ret = 0;
string spname = "sp_UpdateAd";
try
{
//Retrieve the parameters from the cache
SqlParameter[] storedParams =
SqlHelperParameterCache.GetCachedParameterSet( connString, spname );
if( storedParams == null )
{
//Cache the parameters
SqlParameter[] paramsToStore = new SqlParameter[]
{

};
SqlHelperParameterCache.CacheParameterSet( connString, spname,
paramsToStore );
storedParams = paramsToStore;
}
ret = SqlHelper.ExecuteNonQuery( _trans, CommandType.StoredProcedure,
spname, storedParams );
}
catch( Exception ex ) { throw; }
finally{} // Do NOT dispose connection

return ret;

Thanks,

--
bic
Oct 4 '07 #1
1 2391

I'd read this:

http://blogs.msdn.com/kcwalina/archi...16/396787.aspx

since you have a "throw", the exception gets bubbled up.

the "page" you have would probably catch the exception, and then display a
message to the user.

in winforms, if you don't handle the exception in the "page", your app will
crash.

in webforms, if you don't handle the exception in the "page", your page will
show a nasty dotnet type exception message.
"bic" <bi*@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
Hi,

Calling my method below how does my page caller display the exception
since
the return type is int?

int ret = 0;
string spname = "sp_UpdateAd";
try
{
//Retrieve the parameters from the cache
SqlParameter[] storedParams =
SqlHelperParameterCache.GetCachedParameterSet( connString, spname );
if( storedParams == null )
{
//Cache the parameters
SqlParameter[] paramsToStore = new SqlParameter[]
{

};
SqlHelperParameterCache.CacheParameterSet( connString, spname,
paramsToStore );
storedParams = paramsToStore;
}
ret = SqlHelper.ExecuteNonQuery( _trans, CommandType.StoredProcedure,
spname, storedParams );
}
catch( Exception ex ) { throw; }
finally{} // Do NOT dispose connection

return ret;

Thanks,

--
bic

Oct 4 '07 #2

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

Similar topics

3
by: Brian | last post by:
I am trying to pass a null value into a stored procedure so that it can save the data. I am using Microsoft's SQLHelper dll to do this. My example code is below. How do I pass in a null value...
11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
0
by: Rajesh Kumar | last post by:
Hi Gregory Thanks for your answer. I did not see any attached file so I copied your text into a text file and named it compiler.bat Checked the wrapped lines and runned the file. It said Dataset,...
0
by: Rajesh Madhra | last post by:
Hi Gregory Thanks for your answer. I did not see any attached file so I copied your text into a text file and named it compiler.bat Checked the wrapped lines and runned the file. It said Dataset,...
7
by: Neven Klofutar | last post by:
Hi, I have a problem with SqlHelper.ExecuteScalar ... When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.". ...
4
by: John F | last post by:
Hello All, What is the consensus on using sqlhelper or not using sqlhelper when calling stored procedures? We're trying to go with a standard for our projects and personally I prefer not...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.