I'm using C# for end user forms,and what i want to do is to parse the error messages I get from the SQL server.Normally the end user gets the messages like in the picture.Is there a way to parse this and to give the end user what he understands instead of that gibberish there? (like "The Name Test is not permitted in this context .... " as in the picture.)
sql error code
Use Exception.ToString to display a full stack trace. Use Exception.Message to get just the text description part of the error.
In addition, you can look at the SqlException.Class and SqlException.Number properties to make informed decisions about how to handle these exceptions in your code. The SqlException.Number property will correspond to an entry in the sys.messages view. 1205, for example, is the number for a deadlock exception. And if SqlException.Class = 11, then that is a concurrency exception.
The SqlException.Errors property is a list of SqlError objects that contain more detailed information about individual errors. Since a single RPC call to the database can result in multiple exceptions, review these errors to see everything that happened.
exception.ToString() will produce a string like your picture, generally. exception.Message will include just the error message, no stack trace.
When reporting errors in SQL there is always a dilemma where the SQL message needs to convey to the developer what happen, but also provide useful information to a user of the application. We developed a technique of structuring the SQL message into an XML string that provides all the useful information about the error, which allows the caller to use as required. You can see my article on this technique on Code Project at the URL below:
http://www.codeproject.com/Articles/1076477/SQL-Server-Structure-Error-Handling
Related
I am working with Captiva Designer and implemented a flow. In the ODBC setup, I have checked the checkbox which says "Error if more than one row found".
I tested the flow and intentionally used a query which would return multiple rows. However the flow picks up the first query and process next steps accordingly.
How can I fix this issue?
For marking it as error, it will not mean to give any batch level error. However it will mention "More than one row found for fetch", in description attribute, in export module at document level.
you can handle the case accordingly in your flow using the above value.
I have a layered architecture application. All the error handling is done at business layer and data layer throws the error to business layer. Presentation layer shows this custom error to user. Along with that I have a common error page where the HTTP related errors are going. I don’t have any try catch block in presentation layer.
But I need to know the best practice to handle the presentation layer error. Assume like the user expect to enter some decimal numbers, but some characters appended along with that. So how can I handle such kind of error? Should I write code to handle that without writing try catch or should have try catch in my presentation layer code?
Another scenario is I am reading one file from a location, but if the file is not present there, then I should catch this in try catch block or presentation or I should write code for all possible errors?
Thanks
For the presentation layer you should validate user entries.
Add validations on the screens. User entries must be validated before being sent to the server. And also validate your model server-side.
For instance if user is requested to enter a decimal value, check that it is actually a decimal value on the client side and server side next to the form submission.
On the page you may mark the fields that are in error with a red box or a red mark on its right side and display the error message just below the field for instance. That is usually how errors are reported to the user.
You may also choose to display the error message as a tooltip but in any case the field in error must be marked as such.
You can check some demo here: http://scotch.io/demos/angular-validation
Is there a way to get information about other events related the the process, that where not caught by SQL-server profiler (not included in filter list).
For instance, if I only trace the deadlock-graphs and when I catch that kind of event, can I somehow get info about, say, the BatchStarted or BatchCompleted event that happened before/after the caught event inside the same process?
I'm in a situation when I want to know to values of parameters used in the query, but the deadlock-graph event does not provide such info. I can re-configure the profiler to trace other events but I don't know how to reproduce the deadlock.
You cannot get more info that the one you originally traced. But maybe you still don't know that you can get extra event data from your deadlock-graph by right clicking on it and saving the Extra Event Data into a XML file (with XDL extension -Deadlock XML files-, but I suggest to use a XML editor to read it) with a callstack for every process. It may add the extra piece of information that you need to solve your deadlock. Good Luck.
It is perfectly explained here:
http://beyondrelational.com/modules/2/blogs/77/posts/11368/sql-server-ssms-profiler-extracting-deadlock-event-data-to-xdl-files.aspx
I have a Silverlight application that gets down data from the server in the form of an XML string, opens it as a document, and parses through things.
This works on all other machines, but we have client with a user who's machine is unable to run things properly. Her box gives her an InvalidCastException that looks like it's trying to convert 0 to a Double.
This seems like an environmental issue, but I can't figure out what the cause of this would be or how to fix it. Her cultural settings appeared okay, at least for the numeric settings.
Anyone bumped into anything similar or have any next steps for diagnosis or possible fixes? I don't think we can attach to the machine or anything.
Relevant stack trace included below:
[InvalidCast_FromStringTo]
Arguments: 0,Double
Debugging resource strings are unavailable. Often the key and arguments
provide sufficient information to diagnose the problem. See
http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.10411.0&File=Microsoft.VisualBasic.dll&Key=InvalidCast_FromStringTo
Type: System.InvalidCastException
at
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String
Value, NumberFormatInfo NumberFormat)
at MyNamespace.MyLoader.LoadXml(String xml)
Salesforce has thrown a new error message at me, and so far I haven't found anything useful in the docs about this. I am trying to save an object in a controller extension, and it does in fact save the record, but instead of returning to the page that I indicate, it shows me the error message "Hierarchy Constraint Violation". In looking over the debug logs, this does not show up anywhere, despite the fact that I log as error any DML exceptions and re-throw them. I am not stifling any other exceptions, either.
I can't tell what this error even means, let alone where it is coming from.
The problem turns out to be an attempt to create a self reference.