database connections in ASP

database connections in ASP

am 18.10.2004 15:25:25 von evandelagrammaticas

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

Re: database connections in ASP

am 18.10.2004 16:14:39 von Steven Scaife

Try

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

You were setting the conn object then setting it to a string


"Evan" wrote in message
news:53203c78.0410180525.7a4e2cb4@posting.google.com...
> 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

Re: database connections in ASP

am 18.10.2004 18:05:34 von jeff.nospam

On 18 Oct 2004 06:25:25 -0700, evandelagrammaticas@hotmail.com (Evan)
wrote:

>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")

That's an incorrect usage. You created the object, then set it as a
string. What you want is to open the object, as in:

Conn.Open = "PROVIDER=Microsoft.Jet.....

Obviously, since you never opened it, closing it would cause an
error... :)

Jeff

>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