Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

Web Service SQL Connection Model

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Arnold - 31 Jan 2006 07:50 GMT
Hi All,

I am near completion of a project consisting (broadly) of a web app, a web
service and a SQL server - the usual sort of configuration. Both the SQL
server and the web service are tasked with dealing with large amounts of
data per user; and a large number of users.

At the moment I am using a new SqlConnection object for each request to the
web service. Each of these connections is disposed of properly ...

   using (SqlConnection cn = DataService.CreateNewConnection())
   {
       ...
   }

Should I, however, be opening 1 single connection at Application startup and
leaving that open for all requests from all Sessions?

What are the pros & cons of both of these approaches?

Many thanks,

Chris
Miha Markic [MVP C#] - 31 Jan 2006 08:31 GMT
Hi Chris,

You are doing it correctly. Using a global connection is never a good
method.
1. There is no performance hit as connection pool takes care (you might
tweak the number of active connections in the pool through connection
string - see the help files).
2. Doing it this way you are guaranteed that connection is used within
single thread (you can use a single connection only for one operation at
same time).
Just make sure you are disposing connections and everything should be fine.

Signature

Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

> Hi All,
>
[quoted text clipped - 19 lines]
>
> Chris
Cor Ligthert [MVP] - 31 Jan 2006 09:23 GMT
> Just make sure you are disposing connections and everything should be
> fine.

Although for me is closing enough, is the disposing automaticly done by the
"using"  code.

Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.