SQLConnection event catch, please help

A

Amar

I have an SQLConnection object that is being used through all my
webpages of my site. I have a base Web Page that has this Connection,
and all my pages inherit from that one. Is there any way, any event
that i can catch BEFORE any sqlstatement that is being executed with
this connection to handle the statement? I don't want to do it at
every page that i have, i want to make changes at the parent
SQLConnection and that do all the check for me.
 
T

Trevor Benedict R

There is no readymade event that can help you with this, but you can
hide the internal connection and expose that connection through another
class that can handle the event, like if you have an Execute Method on
the connection, you class should also have this and then validate and
then call the Execute method the the connection.

Hope I understood your question in the first place.

Regards,

Trevor Benedict R


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Amar

The problem is that i don't use any Execute Method, i use it in many
different ways e.g.

SqlCommand sCmd = new SqlCommand();
sCmd.Connection = FormConnection ;
sCmd.CommandText = "Select whatever....."

or i use with SqlDataRepeater , or to fill a Dataset..... and so on..

i have tried to use the StateChangeEventHandler of the connection but
the .NET MSDB supports for now only Open and Closed states, there are
some other states like Executing but MSDN declare that (This value is
reserved for future versions of the product.)!!!!!!!!!!!

In other words i want to know every object that uses my connection,
SqlDataDapter or SqlCommand or whatever. I am not sure that this can
be done, maybe it is impossible, but i want to avoid to check any
sqlstatement for every page my project has!!

Thanks again, i hope you understand my english.
 
T

Trevor Benedict R

You are trying to use the Underlying Object & trap the Event at the same
time which is not supported. Hence you have to hide the connection
object inside a class of your own while giving wrapper functions that
would Execute on the Underlying connection and here you will have the
ability to extend each method of property call as required.

Regards,

Trevor Benedict R

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top