database never closes

Discussion in 'ASP .Net' started by et, Sep 29, 2005.

  1. et

    et Guest

    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.
    et, Sep 29, 2005
    #1
    1. Advertising

  2. et

    Landley Guest

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

    L.

    "et" <> wrote in message
    news:%...
    > 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.
    >
    >
    Landley, Sep 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Hirschfeld

    Ending all processes when application closes.

    David Hirschfeld, Nov 11, 2003, in forum: ASP .Net
    Replies:
    13
    Views:
    592
  2. feng
    Replies:
    1
    Views:
    456
    Cowboy \(Gregory A. Beamer\)
    Dec 3, 2003
  3. Soren Kuula
    Replies:
    1
    Views:
    437
    Henry S. Thompson
    Dec 1, 2005
  4. Kevin
    Replies:
    4
    Views:
    409
    Irrwahn Grausewitz
    Oct 17, 2003
  5. Nathan Halterman
    Replies:
    9
    Views:
    132
    Hugh Sasse
    Nov 8, 2008
Loading...

Share This Page