database never closes

E

et

I am using access 2003 and asp.net. I have noticed that when I connect to
my database, create my dataset, populate the page with the dataset, then
close the connection and even dispose of it, it stays open (noticeable by
the "ldb" file created when the database is opened). Eventually when
several people are using the site, I get an Unspecified Connection error,
apparently due to the db always opening but never closing.

This is my code:
Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & HTTPContext.Current.Server.MapPath(".") & "\abc.mdb;"
qry = "select item from tblClients"

'Create the dataset
Dim acConn As New OleDbConnection(strConnection)
Dim cmd As OleDbCommand = new oledbcommand(qry, acConn)
Dim ds As new dataset
Dim da as OleDbDataAdapter = new OleDbDataAdapter(cmd)
acConn.Open()
da.Fill(ds)
acConn.Close
acConn.dispose
Return ds

So what do I need to do to close the database so I don't keep getting
errors, and of course impossible to update the database. On my local
server, I can delete the aspnet_wp.exe from the task manager, then I can
delete the ldb file, then the database is no longer open, but I cannot do
that on my actual web host, I am using someone else's server for that.
 
L

Landley

You haven't cleaned up the dataadapter and command object. Try this and let
me know how you get on.

L.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top