C# .NET - Exception filters and extendable stored procedures

Asked By Kalyan Sagar
10-Feb-12 03:16 AM
what are exception filters ? what is the use of them? what is the use of extendable stored procedures? 

why should not we  re throw the ex; why should we need to preserve the original call stack? for what purpose?

try 
{
}
catch( exception ex)
{
 throw ex;

}
  kalpana aparnathi replied to Kalyan Sagar
10-Feb-12 03:31 AM
What are the Exception Filter?
   
You can handle an exception either by jumping to the level of the exception handler or by continuing execution. Instead of using the exception handler code to handle the exception and falling through, you can use filter to clean up the problem and then, by returning –1, resume normal flow without clearing the stack.

More detail for this http://blogs.msdn.com/b/dotnet/archive/2009/08/25/the-good-and-the-bad-of-exception-filters.aspx.

Use of Expandable stored procedure

Expandable is a great ERP system, but there are some things it just doesn't do. Because the system is built on SQL Server you have the option of creating triggers and stored procedures in your database to accomplish the things that everyone has always said "Expandable can't do that!" In this session John Borges takes you through what triggers and stored procedures are and how they can be used to enhance Expandable. Included will be examples of each that he has implemented to greatly improve productivity and decrease the need for reports.

For retheow:

You haven't handled the exception fully (or at all) in your policy, but as you've caught it, the exception no longer exists so rethrowing it just makes sure it will ripple up the stack.  If you don't rethrow it you will simply cause the exception to disappear.


  Somesh Yadav replied to Kalyan Sagar
10-Feb-12 04:25 AM
Hi,
exception filters:-

Exception filters allow you to specify a conditional clause for each catch block.  Instead of a catch block handling all exceptions of a specific type, they allow us to write catch blocks that handle exceptions of a specific type (or all exceptions) only when a certain condition is true.  For example, consider the following Visual Basic .NET code:

Try
        ' do something that could throw an exception
Catch e As FileNotFoundException When MyFilterMethod(e)
      Console.WriteLine(“first“)

Catch e As FileNotFoundException When MyFilterMethod2(e)
      Console.WriteLine(“second“)
Catch e As FileNotFoundException When MyFilterMethod3(e)
      Console.WriteLine(“third“)
Catch e As DivideByZeroException
    Console.WriteLine(“fourth“)
End Try


use of extendable stored procedures:-

Extended stored procedures are a very powerful way to extend the functionality of SQL Server. The following excerpt is from the SQL Server Books Online:
Extended stored procedures provide a way to dynamically load and execute a function within a dynamic-link library (DLL) in a manner similar to that of a stored procedure, seamlessly extending SQL Server functionality. Actions outside of SQL Server can be easily triggered and external information returned to SQL Server. Return status codes and output parameters (identical to their counterparts in regular stored procedures) are also supported. SQL Server includes system stored procedures that add (sp_addextendedproc), drop (sp_dropextendedproc), and provide information about (sp_helpextededproc) extended stored procedures.
You must treat the extended stored procedure DLL as any other DLL development: It is shared code, and multiple threads can access it at the same time. As with any production-worthy project, make sure to use thorough design and complete testing.

For re throw :- you havnt handled the exception fully in your policy, but as you have caught it, the exception no longer exists so rethrowing it just makes sure it will ripple up the stack.if youdont rethrow it you will simply cause the exception to disappear.

hope it helps you.

Create New Account
help
SQL Server 2005 SQL Server SQL Server installed in my XP Prof with Visual Studio 2005. I do not know how to make it running. SQL Server(SQLEXPRESS) is Running. I do not see how to create a table. Please, Help
Cannot install ANY flavor of SQL Server SQL Server So far, I have tried: Visual Studio 2005 (SQL Express) SQL Server 2005 Express SQL Server 2005 Standard Visual Studio 2008 SQL Server 2008 with completely uninstalling
strawberry perl and sql server SQL Server I need to connect to sql server from strawberry perl. Is anyone aware of any free driver for this. thanks. SQL Server Discussions SQL Server 2005 (1) SQL Server 2000 (1) SQL Express (1) SQL Server (1
reporting options in SQl Server SQL Server What are the options to do SQL Server reports? I have done Access frontend SQL Server backend reports in Access. I have a client with SQL Server. He has Filemaker for
SSIS package in sql server 2008 SQL Server I am using sql server 2000 and want to move to sql server 2008 How to create / edit a ssis(dts) package in sql server 2008? Previously i