consider there is n-tier architecture in asp.net 3.5 application with c# language and Database in the sql server 2008.
Suppose we called the stored procedure exist in database, in our data access layer. But while execution of the stored procedure ,It gets exception. (which may facilitate to throw out in stored procedure) then how application know what is the exception exactly?
Is ADO.NET have capability to understand and represent the thrown exceptions by sql sql server. I know there is SQLException namespace provided by CLR's exception handling module. but as per my experience, this module can not represent the validation exceptions as it is encountered in sql server. Can somebody correct me and guide properly in handling the sql server exceptions form the dot net application ? and how we can handle them ? are we need to wait for execution/ reach at catch block always in dataaccess layer?
May be this question repeats, but I want to share my experience.
You should be validating and/or sanitising all the data that has been input before it reaches the database, so unless the DB is not present or there is a bug in a SP you shouldn't really get SQL exceptions.
From my experience you would catch the SQL Exception log it, wrap it in an ApplicationException and return a user friendly error to the UI.
Related
I want to execute database operation in a handler and then send three commands to other handlers.
I want to make sure that all the execution of database operation together with sending commands occur in a transaction and whether all succeed or all fail.
I am using .net core and when I try to do this I get an exception that "This platform does not support distributed Transactions"
I was using RabbitMQ Transport and then SQL server transport but still getting the same problem.
I would like to know the best way to ensure that all the execution is ATOMIC under .NET Core and RabbitMQ or SQL Server transport.
Thanks
I am surprised that you get this particular exception, because Rebus does not participate in distributed transactions (at least not with any of the supported transports, and especially not with RabbitMQ).
Could you maybe update your question to include the full exception details (with stack trace and everything)? And maybe tell a little bit about how you're performing your database operations?
I want to know , If I can catch all errors occurred in my database and log it to some user defined table.
Reason:
Why I am as so is that, I have web-app running with Sql2005 as backend. Web app is developed using Linq2Sql. It was developed on 2008R2 where as deployed over Sql2005 on a Shared Hosting environment.
I am continuously getting datetime datatype error, as in 2008 i have used date datatype.
So, what I want is to catch any similar exceptions internally , occurred anywhere in my database and log it to my custom table with fields
Requirements
Table Name from where the exception has been thrown
Name of Procedure, in case if I use it in future
Exception message
Date time of occurrence
Please Note
I dont want to write tablewise exception handling procedures. I want some generic way to get all exceptions, as same as we handle errors in ASP.Net , Global.asax.
Exception I am getting
The version of SQL Server in use does not support datatype 'date'.
based on above exception, I am not sure which table is throwing this exception. So I want a stored procedure to catch the detail and save to my custom table.
Those errors aren't internal to SQL server. It's probably not even SQL that's giving it to you but rather the db drivers.
If you are using stored procedures, then SQL server would have prevented those s'procs from even being created with the unsupported data type usage.
Considering you are using LINQ, my guess is that LINQ itself is throwing the problem and you'll need to use your regular exception handling around database calls to find it.
Of course, a better path, would be to regenerate your model and/or do a code analysis to locate all references to invalid data types. Or, even better, switch to a host that is somewhat up to date with their version of SQL server. There have been a lot of security and performance improvements since then.
I have a web app with a hand-written DAL. It uses Microsoft Application Blocks to actually connect to a MS SQL server database.
When the application is under moderate to heavy load it will return a wrong result set. There is no systematic way to reproduce the error. I can rerun the query in SQL Server Management Studio and get the correct results every time.
I get an error's like the following
DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property
with the name 'TitleName'.
and
System.IndexOutOfRangeException: TitleId at
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
The issue ended up being an AJAX call to a method that used a static SqlConnection object.
This object would be in the connection pool, and would be reassigned to something else and would mutate. So if User A is loading the page when the AJAX method was called and User B is Requesting a page and get's User A's Static connection calamity occurs.
I've been researching for days and I've gotten to the point where my WCF service creates an Access object via com/interop. I've ran the OpenCurrentDatabase call for the Access object without an error but Application.CurrentDB is still nothing/null. If the CurrentDB is nothing then I surely can't call Application.Run "myFunction" I realize WCF services aren't meant to be user interactive, but it's a long story why I'm trying to go this route. Basically I need to have a proof of concept ready sooner rather than later and the alternative (correct) route involves the complete re-writing of a large complex access VBA application. It's not a permissions issue, I have the IIS user names added to the security tab. What I really need is a way to set Environment.UserInteractive to true so my WCF service can create an instance of Access on my server machine, run the VBA functions, close out, return true. I'm using VS 2010 for the WCF, IIS 7 for my server, Access 2010 for the VBA application. Please help!
The answer is to have the WCF service write the access macro name to a database and have a desktop application on the server machine monitor the database. The desktop application loads access, performs the actions, and writes back to the database upon completion. The WCF service monitors the database waiting for an "operation complete" status and returns the result.
I want to design a bullet-proof, fault tolerant, DB driven web application and was wondering on how to architect it.
the system will have a asp.net UI, web services middle tier and SQL2005 back end. The UI and Services will communicate using JSON calls.
I was wondering on how to ensure transactions are committed and if not for any error to bubble up and be logged. ideally the action to be retried a couple times after 5 minute intervals, like an email app does.
I was planing to use try catch blocks in SQL and was wondering what the interface (or contract if you will) would look like between the SQL stored procs and the Services that call them would look/ function. this interface will play 2 roles one is to pass params for the proc to function and return expected results. the next will be for the proc to return error information. maybe somethign like error number and error message.
my quagmire is how to i structure this intelligently so that the services expect and react accordingly to both data and error info returned from procs and handle each accordingly?
is there a framework for this because it seems very boiler plate?
You might consider looking into SQL Server Service Broker:
http://msdn.microsoft.com/en-us/library/ms345108%28v=sql.90%29.aspx
The unique features of Service Broker
and its deep database integration make
it an ideal platform for building a
new class of loosely coupled services
for database applications. Service
Broker not only brings asynchronous,
queued messaging to database
applications but significantly expands
the state of the art for reliable
messaging.