Computing.Net > Forums > Programming > ADO.Net MSDE connection problems

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ADO.Net MSDE connection problems

Reply to Message Icon

Name: hjxfabio
Date: February 6, 2006 at 20:18:10 Pacific
OS: XP
CPU/Ram: 1.7/512
Comment:

I am having a serious problem which I do not know how to solve. I have written a program with VB.net 2002 and MSDE as the database. However after deploying it at customer's place, they reflected to me an error indicating that the ADO.net connection is closed from time to time. It's not consistent. I would like to know that could it be something to do with MSDE limitations, my coding problems or some others? Please do advice. Do I have to open a database connection, do my select statement and close the database connection immediately after that? or can I open the database connection and close only after the user closes the connection? Currently I am doing the latter way. Please help. Thank you.



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: February 6, 2006 at 20:51:46 Pacific
Reply:

The correct way to do it is to open the connection, get what you need, then close it.

Good luck,
-SN


0

Response Number 2
Name: hjxfabio
Date: February 7, 2006 at 17:34:17 Pacific
Reply:

Thanks for replying. Do you mean, for example, the OLEDB.OledbConnection that I have to close after every transaction to the MSDE database? Please advice. Thanks a lot.


0

Response Number 3
Name: SN
Date: February 7, 2006 at 18:12:52 Pacific
Reply:

First of all, you shouldn't be using the OLEDB.OledbConnection at all...MSDE will allow you to use the objects in the System.Data.Sql and System.Data.SqlTypes namespaces, which will provide you with much better performance and a better coding interface.

But yes, you have to close the connection after you're done with it. Something like this:
Dim cn as new SqlConnection(strConnectionString)
cn.Open()
//make command object, call a stored procedure, etc.
cn.Close()

In cases where you know you'll be making several queries to the database in a row, (ie one query to get a row in a person table, then another query to get all that person's orders in a transaction table)you'll get better performance if you wait until you're completely done to close the connection. But you definitely shouldn't have any connections open while waiting around for the user to do something.

Good luck,
-SN


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: ADO.Net MSDE connection problems

help with insering rows in ADO.NET www.computing.net/answers/programming/help-with-insering-rows-in-adonet/13370.html

Data Error in VB.NET OLEDB www.computing.net/answers/programming/data-error-in-vbnet-oledb/13196.html

VB.net 2002 Deployment Problem www.computing.net/answers/programming/vbnet-2002-deployment-problem/13797.html