473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.NET - Desktop App - DB Connections

Hello,

I come from a mostly web application background, but am currently working on
a desktop app to be designed using VB.NET. The app will have around 15
users; I don't expect that amount to increase significantly.

I'm trying to decide on which approach to use in regards to database
connection handling. Should I open my database connection (to SQL Server)
on application startup and hold it for the user's entire session (meaning
that each user will have 1 dedicated DB connection) or do I go with the
approach I'm more familiar with using on web apps where you open and close
DB connections as you need them.

Most of the guys here are telling me that the first approach is generally
how it's done on client server apps with a small amount of users, but once
again, given my background, I feel a bit uncomfortable with that route.

Any advice from you experience windows programmers out there?

Thanks,
Leo
Nov 21 '05 #1
4 2136
In my opinion it would depend on usage.
If the app is constantly hitting the database, leave the connection open.
If you are just querying out some stuff in the beginning and not going back to
it regularly, I would close it.
Of course if you want to keep the recordset open, then might need to keep it
open.
Connecting and disconnecting can sometimes take a little while (seconds), but if
it has to be re-established often, then this can annoy the users.
Additionally, depending upon your configuration, your server might have a time
out, and after a period of inactivity it might disconnect you anyway, in which
case you might get a run-time error if you think it should be open. Don't see
this too often with SQL, but pops up with Oracle a lot.

I have apps that use both methods.
Opening and keeping open is the "easy" and sometimes lazy way.
But like I said, the "right" choice depends on what you are doing.

Gerald

"Leo J. Hart IV" <le******@fmr.com> wrote in message
news:b6*************************@posting.google.co m...
Hello,

I come from a mostly web application background, but am currently working on
a desktop app to be designed using VB.NET. The app will have around 15
users; I don't expect that amount to increase significantly.

I'm trying to decide on which approach to use in regards to database
connection handling. Should I open my database connection (to SQL Server)
on application startup and hold it for the user's entire session (meaning
that each user will have 1 dedicated DB connection) or do I go with the
approach I'm more familiar with using on web apps where you open and close
DB connections as you need them.

Most of the guys here are telling me that the first approach is generally
how it's done on client server apps with a small amount of users, but once
again, given my background, I feel a bit uncomfortable with that route.

Any advice from you experience windows programmers out there?

Thanks,
Leo

Nov 21 '05 #2
The user will be constantly querying and sending updates to the
database, so it sounds like I SHOULD be using the "1 connection per
user" method, given your response.

It just seems so foreign to me since the general rule of thumb in web
apps is: open the connection as late as possible, close the connection
as quickly as possible.

Another question: wouldn't the time to "open" and "close" connections be
rather minimal if using connection pooling?

Thanks,
Leo

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
In this case, since it is a desktop app and not a web app, then my decision
would be to use the "1 connection per user" method. As long as you have need to
access the connection regularly, keep it open.

This is indeed a different paradigm than web apps.
Since web apps are "stateless" and you have no control over client responses, it
is not safe to attempt to keep connections open. This you know. But with desktop
apps, you have much more control over things, so it is much safer. Just make
sure to close it when you don't need it anymore, and/or when your application
closes.

As far as your question on connection pooling, my needs don't generally deal
with this so I can't provide an experienced reply.

Gerald

"Leo Hart" <le******@fmr.com> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
The user will be constantly querying and sending updates to the
database, so it sounds like I SHOULD be using the "1 connection per
user" method, given your response.

It just seems so foreign to me since the general rule of thumb in web
apps is: open the connection as late as possible, close the connection
as quickly as possible.

Another question: wouldn't the time to "open" and "close" connections be
rather minimal if using connection pooling?

Thanks,
Leo

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

Nov 21 '05 #4
Thanks for all of your assistance Gerald!

Leo
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
0
by: Glenn Leifheit | last post by:
Any thoughts on how I could find out how many users and there ID's are logged into a server remotely, using Remote Desktop. I have looked through System.Net.Sockets, and WMI, but have not found...
2
by: James | last post by:
Dear Access Guru's, Hopefully you can help me (as Microsoft don't seem to be able to) We have an Access database on a Windows 2003 server with 5 CALS in our office. Access is loaded onto...
2
by: Bob | last post by:
We have a production web site that's data intensive (save user input to DB and query for displaying) with the ASP.NET app part on one W2K server and SQL 2000 DB on another W2K server. I have set...
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
3
by: Daniel Liberman | last post by:
Hi, everyone. That's my environment: - I have a pocket pc (iPAQ h4350) application developed with VSNET2003/C# that has a SQL Server CE Database, running. That's working fine. Obs: the pocket...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
2
by: CLM | last post by:
When I test the remote access at work (lapttop computer to desk top computer) the connection works fine. When I bring the laptop home and try to connect to my desktop I get the error msg: The...
3
by: jx2 | last post by:
Hi everyone, i made java database desktop application,(using persistence) I want to use this application on a different computer, I used derbyDB (network driver) is it possible to change it to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.