ado connection problem

P

Paul M

Hi
I have created a connection to a database but I get the following error
What can be the cause of such an error
.........................................................................
ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed
or invalid in this context.

........................................................................................

Here is the code


If Len(ipMemberID)>0 AND IsNumeric(ipMemberID) Then
sUpdate="SELECT * FROM tblMembers WHERE ID=" & ipMemberID
Set opConnection=Server.CreateObject("ADODB.Connection")
Set opRecordset=Server.CreateObject("ADODB.Recordset")
opRecordset.open sUpdate, opConnection
If NOT opRecordset.Eof Then



sUpdate = "UPDATE ( sql here)


opConnection.execute(sUpdate)

'Close the recordset object
opRecordset.Close
Set opRecordset=Nothing
%>
 
S

Stefan B Rusynko

No need to open the record set or check if it is found
- If the ipMemberID is not found, no update will occur

Plus you need to first open your DB connection, and set the Command Type to &H0001

If value1 is a text value, and field1 is the field you are updating then:

IF Len(ipMemberID)>0 AND IsNumeric(ipMemberID) THEN
sUpdate = "UPDATE tblMembers Set field1='" & value1 & " WHERE ID=" & ipMemberID
Const ADOadCmdText = &H0001
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ConnStr 'where ConnStr is your DB connection string to open the DB
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = sUpdate
objCmd.CommandType = ADOadCmdText
objCmd.Execute
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing
END IF


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Hi
| I have created a connection to a database but I get the following error
| What can be the cause of such an error
| ........................................................................
| ADODB.Recordset error '800a0e7d'
|
| The connection cannot be used to perform this operation. It is either closed
| or invalid in this context.
|
| .......................................................................................
|
| Here is the code
|
|
| If Len(ipMemberID)>0 AND IsNumeric(ipMemberID) Then
| sUpdate="SELECT * FROM tblMembers WHERE ID=" & ipMemberID
| Set opConnection=Server.CreateObject("ADODB.Connection")
| Set opRecordset=Server.CreateObject("ADODB.Recordset")
| opRecordset.open sUpdate, opConnection
| If NOT opRecordset.Eof Then
|
|
|
| sUpdate = "UPDATE ( sql here)
|
|
| opConnection.execute(sUpdate)
|
| 'Close the recordset object
| opRecordset.Close
| Set opRecordset=Nothing
| %>
|
|
 

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

Top