Closing the connection

E

Evan

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
 
L

Lucas Tam

(e-mail address removed) (Evan) wrote in
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 : )
 
N

Norman Yuan

Wrong NG, but.. see comment in line

Evan said:
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
 

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

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top