Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Connections, recordsets, all kinds of errors!


Message #1 by "Elizabeth Gusztak" <elizabeth.gusztak@e...> on Wed, 28 Mar 2001 22:10:52
Here is my code:



Set DB = Server.CreateObject("ADODB.Connection")

DB.Mode = 3 'adModeReadWrite

DB.Open "pics","",""



set RS = Server.CreateObject("ADODB.Recordset")

RS.CursorType = 3 'adOpenStatic

RS.Open sSQLFindName*

RS.Movelast

sFileName = RS("filename")

RS.Close

set RS = nothing



*error message: Operation is not allowed on an object referencing a closed 

or invalid connection



So I commented out the lines having to do with RS, and (some of) the 

following Update queries I do using DB.Execute() work properly.



the other version I try has the RS lines first, and they work.  Then when 

I create the connection below, it comes up with another error: Could not 

use '(unknown)'; file already in use. 

(It isn't really in use, there is no .ldb file!)

What is wrong with my code, or my understanding of these objects??
Message #2 by "Markus Hain" <kill@g...> on Thu, 29 Mar 2001 07:43:21
> Here is my code:

> 

> Set DB = Server.CreateObject("ADODB.Connection")

> DB.Mode = 3 'adModeReadWrite

> DB.Open "pics","",""

> 

> set RS = Server.CreateObject("ADODB.Recordset")

> RS.CursorType = 3 'adOpenStatic

> RS.Open sSQLFindName*

> RS.Movelast

> sFileName = RS("filename")

> RS.Close

> set RS = nothing

> 

> *error message: Operation is not allowed on an object referencing a 

closed 

> or invalid connection

> 

> So I commented out the lines having to do with RS, and (some of) the 

> following Update queries I do using DB.Execute() work properly.

> 

> the other version I try has the RS lines first, and they work.  Then 

when 

> I create the connection below, it comes up with another error: Could not 

> use '(unknown)'; file already in use. 

> (It isn't really in use, there is no .ldb file!)



Can you give some more detail on what you are trying to do ? It looks like 

you are closing the recordset before your data is retrieved, also why do 

you want the rs to go to the last record immediately ?



Markus

Message #3 by "Dallas Martin" <dmartin@z...> on Thu, 29 Mar 2001 06:55:40 -0500
You must create and open the connection first. Then reference it in your

instruction to oprn the recordset.

Here's an example of the proper syntax. The "ad" constants can be found in

the "adovbs.inc" file..



'*** Open tables: sql, connection, cursortype, locktype, options

rsTable.Open strSQL, cnConn, adOpenForwardOnly, adLockReadOnly, adCmdText



strSQL  is the sql string, i.e. "SELECT this FROM that"

cnConn is the connection which was created first

adOpenForwardOnly instructs the database server to return a forward

scrolling record set only

adLockReadOnly means that the returned recordset cannot be updated

adCmdText tells the database (actually the ODBC/OLE DB drivers) that the SQL

string must be examined for proper syntax.



hth

Dallas Martin









----- Original Message -----

From: "Markus Hain" <kill@g...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, March 29, 2001 7:43 AM

Subject: [asp_databases] Re: Connections, recordsets, all kinds of errors!





> > Here is my code:

> >

> > Set DB = Server.CreateObject("ADODB.Connection")

> > DB.Mode = 3 'adModeReadWrite

> > DB.Open "pics","",""

> >

> > set RS = Server.CreateObject("ADODB.Recordset")

> > RS.CursorType = 3 'adOpenStatic

> > RS.Open sSQLFindName*

> > RS.Movelast

> > sFileName = RS("filename")

> > RS.Close

> > set RS = nothing

> >

> > *error message: Operation is not allowed on an object referencing a

> closed

> > or invalid connection

> >

> > So I commented out the lines having to do with RS, and (some of) the

> > following Update queries I do using DB.Execute() work properly.

> >

> > the other version I try has the RS lines first, and they work.  Then

> when

> > I create the connection below, it comes up with another error: Could not

> > use '(unknown)'; file already in use.

> > (It isn't really in use, there is no .ldb file!)

>

> Can you give some more detail on what you are trying to do ? It looks like

> you are closing the recordset before your data is retrieved, also why do

> you want the rs to go to the last record immediately ?

>

> Markus

>

  Return to Index