Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error Type:ADODB.Recordset (0x800A0E7D) The connection cannot be used to perform this operation. It is either closed or invalid in this context.

Posted on 2006-04-25
7
Medium Priority
?
2,188 Views
Last Modified: 2008-01-09

Hi:
  I am using a DSN less connection to update the alumni information upon clicking the submit button to an access database.This is the code that I have used.

Dim adocon
Dim strsql

If Request.Form("B1")= "Submit" Then
'-- Create a new SQL string--
strsql = "Select * FROM AlumniMembers"
'-- Create a new recordsheet--
Set adocon = Server.CreateObject("ADODB.Recordset")
adocon.Open "DBQ= " & Server.MapPath("/informs.mdb") &"; Driver = {Microsoft Access Driver(*.mdb)};"  
adocon.Open "DSN=informs"
adocon.CursorType=2
adocon.LockType=3
'--Open recordsheet and execute SQL string
adocon.open strsql,adocon
'--Set recordsheet to add a new record --
adocon.Addnew
      '-- Add records to database from form --      
                  adocon.Fields("Firstname") = Request.Form("firstname")
                adocon.Fields("Lastname") = Request.Form("lastname")
                adocon.Fields("Homeaddress") = Request.Form("address")
                adocon.Fields("city") = Request.Form("city")
                adocon.Fields("state") = Request.Form("state")
                adocon.Fields("zipcode") = Request.Form("zipcode")
                adocon.Fields("e-mail") = Request.Form("email")
                adocon.Fields("web-page") = Request.Form("webpage")
                adocon.Fields("graduation degree") = Request.Form("graddegree")
                adocon.Fields("graduation year") = Request.Form("gradyear")
                adocon.Fields("department") = Request.Form("department")
                adocon.Fields("degree advisor") = Request.Form("advisor")
                adocon.Fields("Professional interest") = Request.Form("interest")
                adocon.Fields("company") = Request.Form("company")
                adocon.Fields("company address") = Request.Form("compaddress")
                adocon.Fields("c_city") = Request.Form("pcity")
                adocon.Fields("c_state") = Request.Form("pstate")
                adocon.Fields("c_zip code") = Request.Form("pzipcode")
                adocon.Fields("c_web page") = Request.Form("pwebpage")
            '--Update the recordsheet
            adocon.Update
            '-- Close and clean
            adocon.Close
            Set adocon = Nothing
                   %>

Upon compiling I get the following error.

"Error Type:ADODB.Recordset (0x800A0E7D) The connection cannot be used to perform this operation. It is either closed or invalid in this context"
.
What is wrong with the code.Please help?
                                                                         Jagdish.l

0
Comment
Question by:abhishek_p
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
John_Lennon earned 500 total points
ID: 16537532
i guess here are the problem

Set adocon = Server.CreateObject("ADODB.Recordset") '<-- are this a recordset or a connection?
adocon.Open "DBQ= " & Server.MapPath("/informs.mdb") &"; Driver = {Microsoft Access Driver(*.mdb)};"  
adocon.Open "DSN=informs" '<--- Seems like a connection
adocon.CursorType=2
adocon.LockType=3
'--Open recordsheet and execute SQL string
adocon.open strsql,adocon '<-- but you are here using it like a recordset

try this instead
set conn = server.createObject("ADODB.Connection")
Set adocon = Server.CreateObject("ADODB.Recordset")
conn.Open "DBQ= " & Server.MapPath("/informs.mdb") &"; Driver = {Microsoft Access Driver(*.mdb)};"  
'--Open recordsheet and execute SQL string
adocon.open strsql,conn '

--Set recordsheet to add a new record --
adocon.Addnew
     '-- Add records to database from form --    
               adocon.Fields("Firstname") = Request.Form("firstname")
              adocon.Fields("Lastname") = Request.Form("lastname")
              adocon.Fields("Homeaddress") = Request.Form("address")
              adocon.Fields("city") = Request.Form("city")
              adocon.Fields("state") = Request.Form("state")
              adocon.Fields("zipcode") = Request.Form("zipcode")
              adocon.Fields("e-mail") = Request.Form("email")
              adocon.Fields("web-page") = Request.Form("webpage")
              adocon.Fields("graduation degree") = Request.Form("graddegree")
              adocon.Fields("graduation year") = Request.Form("gradyear")
              adocon.Fields("department") = Request.Form("department")
              adocon.Fields("degree advisor") = Request.Form("advisor")
              adocon.Fields("Professional interest") = Request.Form("interest")
              adocon.Fields("company") = Request.Form("company")
              adocon.Fields("company address") = Request.Form("compaddress")
              adocon.Fields("c_city") = Request.Form("pcity")
              adocon.Fields("c_state") = Request.Form("pstate")
              adocon.Fields("c_zip code") = Request.Form("pzipcode")
              adocon.Fields("c_web page") = Request.Form("pwebpage")
          '--Update the recordsheet
          adocon.Update
          '-- Close and clean
          adocon.Close
          Set adocon = Nothing
conn.close
set conn = nothing
0
 
LVL 7

Expert Comment

by:Cherukuri30
ID: 16538147
thats right remove adocon.Open "DSN=informs"
0
 

Author Comment

by:abhishek_p
ID: 16541220

 Upon trying the above code right now I am getting the following error below

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/Informs/membership_form.asp, line 37


 
0
 
LVL 7

Expert Comment

by:Cherukuri30
ID: 16541232
0
 
LVL 6

Expert Comment

by:John_Lennon
ID: 16544680
line 37?

what is line 37 in the code?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question