.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Error handling, multiple error messages

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :Sql Server
Hi all. Have you noticed that sql server catches only last error message? Try to run this: exec('create table #t ( t1 timestamp not null default 0 )') You get: Msg 1755, Level 16, State 0, Line 1 Defaults cannot be created on columns of data type timestamp. Table '#t', column 't1'. Msg 1750, Level 16, State 0, Line 1 Could not create constraint. See previous errors. Now try to run the same thing in try catch: begin try exec('create table #t ( t1 timestamp not null default 0 )') end try begin catch declare @Error varchar(max) set @Error = error_message() raiserror(@Error, 16, 1) end catch The error message this time is: Msg 50000, Level 16, State 1, Line 10 Could not create constraint. See previous errors. Does anyone have any better ideas how to handle sql server errors? Thanks      

View Complete Post

More Related Resource Links

Handling 404 page not found with Error page



      How do i handle 404 page not found?

Error: Encountered multiple versions of the same assembly with GUID...try pre-importing...TlbImp


Hi!  Can someone tell me how I can troubleshoot the following error: "Encountered multiple versions of the same assembly with GUID...try pre-importing one of these assemblies".

The website developed in VS 2010 (.Net 3.5). This error is only received on my workstation.  Another person developing the site does not experience this issue at all.  Also, not sure if this matters, but on my workstation the 'Assembly Information...' dialog contains no values even though the 'AssemblyInfo.vb' file does specify values for the title, desc, etc.  The GUID being referenced in the error is the main project of the three projects within the solution.

I tried looking through the GAC, but do not see any references to the projects or DLLs in the VS solution and am not sure what else/where to look.

If I delete the copy of the solution on my local machine and pull down a copy from source control (AnkhSVN) the solution will build with no error.  Once I make any changes, such as adding a new aspx file, then the error is received.

I can provide any additional information needed.

Error while using exception handling block el 4.1


Hi Folks,


i am trying to use tyhe exception handling block of Enterprise library 4.1.


I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.


During runtime I am getting an exception on the HandleException event, The exception is added below:



Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

Foundations: Error Handling In Workflows


Workflows often define long-running processes and an unhandled failure usually means termination. Avoid this scenario by handling exceptions properly.

Matt Milner

MSDN Magazine February 2009

Error Handling: Throwing Custom Exception Types from a Managed COM+ Server Application


Exception handling semantics in .NET are based on type, so you can create custom exceptions that have their own properties and methods. In .NET, exceptions are first-class citizens, and since they're the built-in error handling mechanism, all .NET-compliant languages must support exceptions. In addition, COM+ services are available to .NET code as Enterprise Services, so you can leverage exceptions in your Enterprise Services design.In this article the author describes custom exceptions, throwing exceptions across COM interop boundaries, and working with Enterprise Services.

Bob DeRemer

MSDN Magazine March 2004

.NET Exceptions: Make the Transition from Traditional Visual Basic Error Handling to the Object-Orie


If you're used to Visual Basic 6.0 and you're making the transition to Microsoft .NET, you will find that error handling is quite different from what you've used for years. Visual Basic .NET uses a more object-oriented solution to signaling and responding to unexpected problems while your program is running. This approach, called structured exception handling, has a number of advantages over the On Error statements provided in previous versions of Visual Basic. For instance, exceptions give you lots more information about exactly what went wrong in your app. To help you take advantage of this modern error handling paradigm, this article will show you how to raise and respond to exceptions, as well as how to create your own custom exception classes.

Jesse Liberty

MSDN Magazine November 2002

Propagate Error Info: Use ATL and C++ to Implement Error-Handling COM Objects


Predefined error codes returned from HRESULT aren't always much help for debugging COM C++ code. The C++ macros provided with this article produce an XML file listing the error and its context to make debugging easier. This article begins with an overview of error handling in COM, then discusses the COM interfaces used in the macros. It explains how C++ exceptions are caught and converted to COM-compatible error information, how events are logged with the event viewer, and how context is reported in the description string of IErrorInfo. The macros handle logic errors and errors returned by an object or API.

Panos Kougiouris

MSDN Magazine October 2000

Quick Error messages with Global.asax

The article Quick Error messages with Global.asax was added by lykasd on Wednesday, August 11, 2010.

Error pages without any effort void Application_Error(object sender, EventArgs e) { Server.Transfer("/error.aspx"); //Displays the error page } In error.aspx add this to the content area. p>We're sorry, but the %=Server.GetLastError

Returning custom error messages with an UserNamePasswordValidator

Ok, my head hurts from banging it against the wall. I'm new to WCF, I have searched for a solution for days, please help a desperate fellow programmer if you can :-( I have a WCF service hosted in IIS, I implemented a UserNamePasswordValidator, and it seems impossible to find a way to return a custom error message to the client when the user is not allowed in, this blows my mind. I have searched everywhere, many are asking the same question since 2006 and so far I haven't found an answer that works. If you are thinking of replying that it is not secure to return a custom error message to an unauthenticated client, please save yourself some time and don't do it. There are multiple enterprise business scenarios that this is required. Just in our organization an account could be locked out, in which case the user must be directed to the IT department to get it unlocked, it could be that the credentials are correct but the user hasn't paid their fees in which case they must be directed to the appropriate department, or it could even be that the user tried to access the service during a time of the day in which the service is not available. From searching around, I have tried doing the things below in the Validate method, however the client always receives a MessageSecurityException, which contains none of the custom messages that were originally thrown, neither in the object,

Error using multiple webconfigure file in ASP.Net 3.5

when i using mutiple webconfigure file in .net 3.5 ,error Comes t is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Error When Deploying Multiple Projects in a Solution

We have a solution with 16 projects, where all but 3 are Sharepoint 2010 projects. When we deploy the projects in VS2010 individually, everything is fine, but when we deploy the solution (right-click, deploy), we experience one of two problems: 1. Not all projects get deployed, some just give the following message: "Deployment was not performed for this project because it is a dependent project." 2. Some of the projects (currently always the same three Sharepoint2010 projects) give the following error during the "Recycle IIS Application Pool" step: "Error occurred in deployment step 'Recycle IIS Application Pool': The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout." We don't have any dependencies set up in the projects except for the ones which are automatically created when we add project references. If we do two subsequent solution deployments, the first one will suffer from issue 1 and the second from issue 2 as well. When issue 2 happens, the faulty projects can't even be deployed individually until VS2010 has been restarted.   A Google search has revealed nothing at all. We're at a loss and it's getting to be very frustrating for the entire team. Any help would be appreciated.   Thanks, Bjoern

custom 401/login failure error messages

I have a req to display a custom error message when a user fails to log in 3 times.  The default behavior seem to be for a redirect to something like this http://server/_layouts/AccessDenied.aspx?loginasanotheruser=true&Source=http%3A%2F%2Fserver2k7%2FPages%2FDefault%2Easpx after the third login attempt.  The resulting page just comes up as blank...I'm guessing because it failed auth.  My initial thoughts were to create a custom error page, and redirect with an http module.  That solution (while it does redirect) puts me right back to the initial problem of just a blank page being displayed after the failed auth.  I've been struggling with this for a while now, ANY thoughts or advice would be greaty appreciated.  Is it even possible? 

Best practice for user defined error messages in SQL Server 2005/2008 --Need help

My requirement is to setup a standard practice for our team in handling DB erros and also  user defined messages. We are handling exceptions using Raiseerror method with in Try and Catch blocks.  For user defined message, we are using Sp_addmessage to add our application specific error/warning messages with error codess>80000.  Ex: 80001 | Company name already exists. please check. Here is the sample code ********************************************************************* CREATE PROCEDURE [dbo].[usp_CompanyProfile_insert]  -- Add the parameters for the stored procedure here  (@company_name VARCHAR(50),  @company_code VARCHAR(3),  @user_id INT  ) AS BEGIN  -- SET NOCOUNT ON added to prevent extra result sets from  -- interfering with SELECT statements.  SET NOCOUNT ON;  BEGIN TRY -- Begin Try Block      -- Validate company name   IF EXISTS (SELECT company_id FROM companyprofile WHERE company_name = @company_name)    RAISERROR(90021, 16, 1)      INSERT INTO companyprofile (company_name,       company_code,       createdby)   VALUES(@company_name,     @company_code,     @user_id)    END TRY  -- End Try Block &

Have some error using arraylist in session to store multiple value

i have two buttons in user control, button1 is (like) and second is (dLike). if i click any button the count will increased in my database table by 1. our table have id,title,url,imagegalary,articleid. in everypage i take the article id as in sessioni alredy disable the links when you click once , after i went to next page and come back to the same page the button will visible how to solve this problem. how to store the multiple session values in the arraylist and display it . please anybody replay me protected void ImageButton1_Click(object sender, ImageClickEventArgs e){string ArticleID1 = GenerateArticleID();COLTools.DB.DataBaseType = COLTools.DataBaseType.SqlServer;COLTools.DB.ConnectionString = ConfigurationSettings.AppSettings["COLCMS"].ToString();string updateQuery = "update Article set Alike = Alike + 1 where Articleid =" + ArticleID1;COLTools.DB.RunSql(updateQuery);disablebutton();addtovotelist(ArticleID1);likedislike();}protected void ImageButton2_Click(object sender, ImageClickEventArgs e){string ArticleID1 = GenerateArticleID();COLTools.DB.DataBaseType = COLTools.DataBaseType.SqlServer;COLTools.DB.ConnectionString = ConfigurationSettings.AppSettings["COLCMS"].ToString();string updateQuery = "update Article set Dlike = Dlike + 1 where Articleid =" + ArticleID1;COLTools.DB.RunSql(updateQuery);disablebutton();addtovotelist(A

Error handling on Connection Manager Expression

I am using a connection manager with an expression to set the connection string. (see my question http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/1ea71f9a-df5c-4c1c-a2fd-9e24632afbd8) I would like to put some error handling just incase things go wrong. Can anybody give me some tips on where to place error handling?Mr Shaw

What is the correct error handling in custom model binding?

Hello,I am working on a Custom Model Binder where a certain error can occur.When this happens it returns null and a error is added to the ModelState.The problem is that in some projects I am using Fluent Validation and the errors messages I am adding through FV are not taking effect.The message added by the Model Binder always prevails.Should the Model Binder add error messages or just bind the field and return null if some problem happened?What would be the correct implementation for this?Thanks,Miguel

Stuck during restore process, no error messages

I need to restore a solution (a webpart) from a Sharepoint 2010 backup to another Sharepoint 2010 installation on another server. In CA and exactly in the page _admin/BackupStatus.aspx I see that: A backup or restore is currently in progress. There are no current or recent backup or restore processes to show. If you recently started a backup or restore process, you may need to refresh this page after several minutes for it to appear. Hours have passed since I started the restore process In _admin/ServiceRunningJobs.aspx there is no backup/restore job running. The question is: What can I do to try again a restore if I cannot stop the restore that is "running"? Please Help.  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend