Database Connection and Session State

Discussion in 'ASP .Net Web Services' started by Grigs, Aug 15, 2005.

  1. Grigs

    Grigs Guest

    Hello,

    I have a web service that reads its web.config file to connect to an Oracle
    database. There are a number of methods in this socalled BACKBONE that
    either send inforomation to or from the database. That works great.

    I have the INTERFACE which is what the user sees. When the page is first
    navigated to, it creates an object of the BACKBONE and calls certain Web
    Methods to get data so I may populate dropdown lists and such.

    That works great too. :)

    However, my DBA wanted me to set an action for each "program" that connects
    to his database. I can create this "action" no problem. The only issue is
    that it happens to create 11 entries/connection to the database. Bascially 1
    for each of the 11 seperate calls I make to the BACKBONE.

    I thought I could just create the connection in the BACKBONE's Global.asax
    file as a session variable and use it when I need to connect to the DB but
    that had no difference. Still 11 connections. I understand that the web
    service simple is being called 11 seperate times.

    My question is, is there any way to keep that web-service open? Or some way
    of at least storing the connection in a session variable that will stay? I
    have to believe I am not the only person creating a Web Service to do all of
    the DB grunt work. Are we all wasting connections and the overhead of
    connections connecting? Am I missing something here?

    Please help,
    Thanks in advance
    --
    Thanx,
    Grigs
     
    Grigs, Aug 15, 2005
    #1
    1. Advertising

  2. Web Services, like web apps, are truly stateless, which means that even if
    you have a "session", it's a disconnected session. The clients connect, call
    a method (or methods) and then disconnects. You can use the enableSession
    parameter of the WebMethod attribute, but I don't think that you are going
    to get the results that you want. By default, ADO.NET should be pooling your
    connections, but I am not certain if that is the case when it comes to
    Oracle and their "less than perfect" .Net providers (I know for a fact that
    the SQL Server provider does connection pooling). You might want to contact
    MSFT and/or Oracle about the provider perfomance and see if there is a way
    to enable connection pooling to the database.

    HTH,
    Bill Priess, MCP

    "Grigs" <> wrote in message
    news:...
    > Hello,
    >
    > I have a web service that reads its web.config file to connect to an
    > Oracle
    > database. There are a number of methods in this socalled BACKBONE that
    > either send inforomation to or from the database. That works great.
    >
    > I have the INTERFACE which is what the user sees. When the page is first
    > navigated to, it creates an object of the BACKBONE and calls certain Web
    > Methods to get data so I may populate dropdown lists and such.
    >
    > That works great too. :)
    >
    > However, my DBA wanted me to set an action for each "program" that
    > connects
    > to his database. I can create this "action" no problem. The only issue
    > is
    > that it happens to create 11 entries/connection to the database.
    > Bascially 1
    > for each of the 11 seperate calls I make to the BACKBONE.
    >
    > I thought I could just create the connection in the BACKBONE's Global.asax
    > file as a session variable and use it when I need to connect to the DB but
    > that had no difference. Still 11 connections. I understand that the web
    > service simple is being called 11 seperate times.
    >
    > My question is, is there any way to keep that web-service open? Or some
    > way
    > of at least storing the connection in a session variable that will stay?
    > I
    > have to believe I am not the only person creating a Web Service to do all
    > of
    > the DB grunt work. Are we all wasting connections and the overhead of
    > connections connecting? Am I missing something here?
    >
    > Please help,
    > Thanks in advance
    > --
    > Thanx,
    > Grigs
     
    Bill Priess \(MCP\), Aug 15, 2005
    #2
    1. Advertising

  3. I didn't try it for pooling a connection (Some .net connection object
    are pooled automatically) , but I store session objects like this :

    protected void Session_Start(Object sender, EventArgs e)
    {

    Session.Add("USER_INFO", new myUserinfoObject(User));
    }

    In order to make this works for my web method I put the following:

    .....
    [ WebMethod(Description="blabla",EnableSession=true) ]
    public DataSet getDs()
    {
    ....
    myUserinfoObject= (UserinfoObject)Session["USER_INFO"] ;
    ......

    You may try this for your connection.

    Hope this helps

    http://oraclevsmicrosoft.blogspot.com
     
    oraclevsmicrosoft, Aug 30, 2005
    #3
    1. Advertising

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. shamanthakamani
    Replies:
    1
    Views:
    3,555
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    677
    Not Liking Dot Net Today
    Apr 21, 2004
  3. =?Utf-8?B?R3JpZ3M=?=

    Database Connection and Session State

    =?Utf-8?B?R3JpZ3M=?=, Aug 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    669
    Robbe Morris [C# MVP]
    Aug 16, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    637
    jnickfl1
    Sep 18, 2006
  5. archana
    Replies:
    0
    Views:
    377
    archana
    Mar 13, 2007
Loading...

Share This Page