I have an app that has to connect to various data sources (ms sql server,
sybase, etc...). For this reason I have OdbcConnection, OleDb Connection and
SqlClient objects. When an error happens, I want a single procedure to
handle the error from all the connection types by passing the either the
SqlException, OdbcException or OleDbException.
Unfortunately the object SystemException , that these exceptions have been
derived from, does not have the .Errors collection (like the SqlException,
OdbcException or OleDbException does), so when I pass SystemException into
the procedure and attempt to loop through the Errors collection, it
obviously complains that SystemException does not have such a collection.
Other than overloading the function for each type (which kind of defeats the
purpose of having a single function to handle data related exceptions), can
anyone suggest anything?
--
Frank 1 1980
Frank, Other than overloading the function for each type (which kind of defeats
the purpose of having a single function to handle data related exceptions),
can anyone suggest anything?
Create proxy objects (Adapter Pattern really) for each type of exception
(Data Source), that your single function can then use to access the errors
collection & error objects, generically.
Alternatively create n+1 routines. One for each of the specific exception
classes, then the +1 that the previous n call passing the errors collection,
generically.
In both of the above, read generically as ICollection or IEnumerable, and
methods found on Object (ToString for example).
I think the proxy objects may be the 'easier' route, as the various errors
collections contain objects of different types. If those objects honor
..ToString, this should be easy, otherwise...
Hope this helps
Jay
"Frank Rizzo" <no****@nospam. com> wrote in message
news:uK******** *****@TK2MSFTNG P10.phx.gbl... I have an app that has to connect to various data sources (ms sql server, sybase, etc...). For this reason I have OdbcConnection, OleDb Connection
and SqlClient objects. When an error happens, I want a single procedure to handle the error from all the connection types by passing the either the SqlException, OdbcException or OleDbException.
Unfortunately the object SystemException , that these exceptions have been derived from, does not have the .Errors collection (like the SqlException, OdbcException or OleDbException does), so when I pass SystemException into the procedure and attempt to loop through the Errors collection, it obviously complains that SystemException does not have such a collection.
Other than overloading the function for each type (which kind of defeats
the purpose of having a single function to handle data related exceptions),
can anyone suggest anything?
-- Frank
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Scott Auge |
last post by:
I am looking for comments on something that lets me abstract database
updates in an object.
Lemme explain what I am thinking:
Lets say I have an object Person with...
SetFirstName()
SetLastName()
|
by: Scott Auge |
last post by:
I am looking for comments on something that lets me abstract database
updates in an object.
Lemme explain what I am thinking:
Lets say I have an object Person with...
SetFirstName()
SetLastName()
|
by: nevin |
last post by:
Hi all,
I'm looking at the Amazon web services and get them to work fine. But on any
given call I want to be able to use either the US or the EU schemas which
are in the project as two different web references.
so basically I would like to be able to abstract the objects in each web
service so that I can instantiate either one and pass it...
|
by: Full Decent |
last post by:
Hey all!
I've been using PHP for a while and I'm hearing that I should look into
using it OO. I'm looking into making changes to the program Camera Life
(http://fdcl.sf.net). I want to abstract the connection to the database
which is currently MYSQL and maybe implement another database, or just
leave it open for addition. If I get lucky and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |