Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 29500 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > How to catch a stored procedures exceptions in a code behind using C#.Net? ...
Rajendra.prasad

How to catch a stored procedures exceptions in a code behind using C#.Net?

Replies: 3 | Posted by: Rajendra.prasad on 4/18/2010 | Category: C# Forums | Views: 1227 | Status: [Member]  


Hi All,
How to catch a stored procedures exceptions in a code behind using C#.Net? how to display a stored procedures exceptions in code behind using C#.Net.

Regards,
Rajendra


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vuyiswamb
Vuyiswamb  
Posted on: 4/19/2010 3:23:33 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator]

lets say you want to Execute a StoredProcedure in your DAL, you will have something like this


public voidDisable_Grid_Contents()
{
strcon = GetConnectionString(DB);

con = new SqlConnection(strcon);

cmdselect = new SqlCommand();

cmdselect.CommandText = "dbo.Get_Pattern";

cmdselect.CommandTimeout = 0;

cmdselect.CommandType = CommandType.StoredProcedure;

cmdselect.Connection = con;


try
{
con.Open();

cmdselect.ExecuteNonQuery();
}
catch (SqlException ex)
{
lblErrorMessage.Text = ex.Message; //Your Error willl be display in a Label
}
finally
{
if (con != null)
{
con.Close();
}

}
}


Thank you for posting at Dotnetfunda
[Administrator]

Rajendra.prasad, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Muhilan
Muhilan  
Posted on: 4/20/2010 11:13:43 PM
Level: Starter | Status: [Member]

use SQLExceptions to catch a stored procedures exceptions

Rajendra.prasad, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/18/2013 3:59:59 AM