Database Connection and Session State

G

Grigs

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
 
B

Bill Priess \(MCP\)

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
 
O

oraclevsmicrosoft

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
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top