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 %> Code (markup):
Maybe try closing the recordset before executing the update query. Another thing is, I don't see any End If's to close the blocks.
YOu haven't open the database connection Adding these codes before opRecordset.open sUpdate, opConnection Command Dim ConnStr ConnStr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = "& Server.mappath(Databasefile path here) 'If you are using Access Database. opConnection.Open ConnStr Code (markup):
The reason you are getting this error message is because you are summoning the .open() function before your actually creating the object. This is very confusing to the engine! Even if you do swap the lines around, it will still not work! This is because you have mixed your objects up. The RecordSet object is used to manage the records returned from an SQL query. You are trying to use it to open a connection to a database. You need to use the Connection object rather than the RecordSet object. Regards.