SQLConnection event catch, please help

Discussion in 'ASP .Net' started by Amar, Jun 10, 2004.

  1. Amar

    Amar Guest

    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.
    Amar, Jun 10, 2004
    1. Advertisements

  2. 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.


    Trevor Benedict R

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trevor Benedict R, Jun 10, 2004
    1. Advertisements

  3. Amar

    Amar Guest

    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.
    Amar, Jun 10, 2004
  4. 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.


    Trevor Benedict R

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trevor Benedict R, Jun 11, 2004
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce W.1

    Can't catch Datagrid event! Please help.

    Bruce W.1, Mar 5, 2004, in forum: ASP .Net
    Bruce W.1
    Mar 5, 2004
  2. KK
    Big Brian
    Oct 14, 2003
  3. John Black
    Aug 20, 2004
  4. Adam
    red floyd
    Feb 2, 2006
  5. Marteno Rodia

    catch doesn't catch a thrown exception

    Marteno Rodia, Aug 3, 2009, in forum: Java
    Daniel Pitts
    Aug 5, 2009