Closing the connection

Discussion in 'ASP .Net' started by Evan, Oct 18, 2004.

  1. Evan

    Evan Guest

    Hi guys... I am developing an application and need some advice while
    the application is still in its infancy.

    1. Set Conn = Server.CreateObject("ADODB.Connection")
    2. Conn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    Server.MapPath("documents.mdb")
    3. Set rs = Server.CreateObject("ADODB.Recordset")
    4. SQL="SELECT * FROM users"
    6. rs.close
    7. set rs=nothing

    My question is... is this the most efficient way to connect to the DB
    and shouldnt I be closing my Conn... cause when I try the system says
    that the obj doesnt exist...

    Any advice would be appreciated !

    Evan
    Evan, Oct 18, 2004
    #1
    1. Advertising

  2. Evan

    Lucas Tam Guest

    (Evan) wrote in
    news::

    > 1. Set Conn = Server.CreateObject("ADODB.Connection")
    > 2. Conn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    > Server.MapPath("documents.mdb")
    > 3. Set rs = Server.CreateObject("ADODB.Recordset")
    > 4. SQL="SELECT * FROM users"
    > 6. rs.close
    > 7. set rs=nothing
    >
    > My question is... is this the most efficient way to connect to the DB
    > and shouldnt I be closing my Conn... cause when I try the system says
    > that the obj doesnt exist...


    Wrong group... you should be asking this in a ASP or VB6 group : )

    --
    Lucas Tam ()
    Please delete "REMOVE" from the e-mail address when replying.
    http://members.ebay.com/aboutme/coolspot18/
    Lucas Tam, Oct 18, 2004
    #2
    1. Advertising

  3. Evan

    Norman Yuan Guest

    Wrong NG, but.. see comment in line

    "Evan" <> wrote in message
    news:...
    > Hi guys... I am developing an application and need some advice while
    > the application is still in its infancy.
    >
    > 1. Set Conn = Server.CreateObject("ADODB.Connection")
    > 2. Conn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    > Server.MapPath("documents.mdb")


    'above line should be
    Conn.ConnectionString="Provider......."

    ''Then yo need to Open the connection
    Conn.Open

    > 3. Set rs = Server.CreateObject("ADODB.Recordset")
    > 4. SQL="SELECT * FROM users"


    ''you did not open the recordset, so, you cannot close it.. you need to
    add:

    rs.Open SQL, Conn

    ''then do something here and then close it and then close the connection

    > 6. rs.close
    > 7. set rs=nothing


    Conn.Close

    >
    > My question is... is this the most efficient way to connect to the DB
    > and shouldnt I be closing my Conn... cause when I try the system says
    > that the obj doesnt exist...
    >
    > Any advice would be appreciated !
    >
    > Evan
    Norman Yuan, Oct 18, 2004
    #3
    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. Brent

    Closing database connection.

    Brent, Apr 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    347
    Brent
    Apr 3, 2004
  2. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    649
    Thomas Hansen
    Feb 15, 2007
  3. johnny
    Replies:
    1
    Views:
    791
    Jerry Hill
    Dec 8, 2006
  4. shmuel witman

    Connection timeout (connection closing after 100 sec )

    shmuel witman, Dec 4, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    808
    shmuel witman
    Dec 6, 2005
  5. thomas
    Replies:
    0
    Views:
    226
    thomas
    Oct 23, 2003
Loading...

Share This Page