Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: ADODB.Recordset error '800a0bb9'


Message #1 by "Jeremy Simpson" <jsimpson34@e...> on Tue, 8 Oct 2002 19:44:28
Line 26 "  rsUsers.Open "Person", objConn, adOpenForwardOnly, 
adLockOptimistic, adCmdTable"

caused the following error:

Arguments are of the wrong type, are out of acceptable range, or are in 
conflict with one another. 



<%
  Dim objConn
 Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & 
Server.MapPath("\s3computers\db\Classified.mdb"))
  

  If Session("blnValidUser") = True and Session("PersonID") = "" Then
    Dim rsPersonIDCheck
    Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
    Dim strSQL 
   strSQL = "SELECT PersonID FROM Person " & _ 
             "WHERE EMailAddress = '" & Session("EMailAddress") & "';"
    rsPersonIDCheck.Open strSQL, objConn
    If rsPersonIDCheck.EOF Then
      Session("blnValidUser") = False
    Else
      Session("PersonID") = rsPersonIDCheck("PersonID")
    End If
    rsPersonIDCheck.Close
    Set rsPersonIDCheck = Nothing
  End If

  Dim rsUsers
  Set rsUsers = Server.CreateObject("ADODB.Recordset")
  rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, 
adCmdTable

  If Session("PersonID") <> "" Then                       ' currently 
logged-on user
    rsUsers.Filter = "PersonID = '" & Session("PersonID") & "'"   
  Else                                                                 ' 
New session
    rsUsers.Filter = "EMailAddress = '" & Request.Form("email") & "'" & _ 
                     "AND Password = '" & Request.Form("password") & "'"
    If rsUsers.EOF Then                                             ' User 
not found
      rsUsers.AddNew                                        ' ...so add a 
new record
'   Else 
'     Email address and password matched with DB records - 
'     In this case we'll allow this to update user's personal details
    End If
  End If
                                                  ' write personal details 
to record
  rsUsers("EMailAddress") = Request.Form("email")
  rsUsers("Password") = Request.Form("password")
  rsUsers("FamilyName") = Request.Form("FamilyName")
  rsUsers("GivenName") = Request.Form("GivenName")
  rsUsers("StreetAddress1") = Request.Form("Address1")
  rsUsers("StreetAddress2") = Request.Form("Address2")
  rsUsers("City") = Request.Form("City")
  rsUsers("State") = Request.Form("State")
  rsUsers("PostalCode") = Request.Form("PostalCode")
  rsUsers("Country") = Request.Form("Country")
  rsUsers("Active") = True
  rsUsers("LastLogin") = Now
  rsUsers.Update                                               ' update 
the database

  Dim strName, strValue                                   ' create session 
variables
  For each strField in rsUsers.Fields
    strName = strField.Name
    strValue = strField.value
    Session(strName) = strValue
  Next
  Session("blnValidUser") = True            ' declare that current user is 
validated
  Response.Redirect "MenuForRegisteredUsers.asp"
%>
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 9 Oct 2002 11:23:32 +1000
www.adopenstatic.com/faq/800a0bb9.asp

(put Option Explicit as your first line of code to catch most of these
problems. Also, you can't have an adOpenForwardOnly cursor with an
adLockOptimistic locktype, see:
www.adopenstatic.com/faq/jetcursortypes.asp)

Also, please see the code I posted under the thread "Help, I can't add
fields to the database", which is a much better way of doing what you are
trying to do. The way you are doing it involves really expensive method
calls (opening a whole table with an adOpenStatic cursor, calling .Filter
mulitple times etc)

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Jeremy Simpson" <jsimpson34@e...>
Subject: [access_asp] ADODB.Recordset error '800a0bb9'


: Line 26 "  rsUsers.Open "Person", objConn, adOpenForwardOnly,
: adLockOptimistic, adCmdTable"
:
: caused the following error:
:
: Arguments are of the wrong type, are out of acceptable range, or are in
: conflict with one another.
:
:
:
: <%
:   Dim objConn
:  Set objConn = Server.CreateObject("ADODB.Connection")
:   objConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
: Server.MapPath("\s3computers\db\Classified.mdb"))
:
:
:   If Session("blnValidUser") = True and Session("PersonID") = "" Then
:     Dim rsPersonIDCheck
:     Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
:     Dim strSQL
:    strSQL = "SELECT PersonID FROM Person " & _
:              "WHERE EMailAddress = '" & Session("EMailAddress") & "';"
:     rsPersonIDCheck.Open strSQL, objConn
:     If rsPersonIDCheck.EOF Then
:       Session("blnValidUser") = False
:     Else
:       Session("PersonID") = rsPersonIDCheck("PersonID")
:     End If
:     rsPersonIDCheck.Close
:     Set rsPersonIDCheck = Nothing
:   End If
:
:   Dim rsUsers
:   Set rsUsers = Server.CreateObject("ADODB.Recordset")
:   rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic,
: adCmdTable
:
:   If Session("PersonID") <> "" Then                       ' currently
: logged-on user
:     rsUsers.Filter = "PersonID = '" & Session("PersonID") & "'"
:   Else                                                                 '
: New session
:     rsUsers.Filter = "EMailAddress = '" & Request.Form("email") & "'" & _
:                      "AND Password = '" & Request.Form("password") & "'"
:     If rsUsers.EOF Then                                             ' User
: not found
:       rsUsers.AddNew                                        ' ...so add a
: new record
: '   Else
: '     Email address and password matched with DB records -
: '     In this case we'll allow this to update user's personal details
:     End If
:   End If
:                                                   ' write personal details
: to record
:   rsUsers("EMailAddress") = Request.Form("email")
:   rsUsers("Password") = Request.Form("password")
:   rsUsers("FamilyName") = Request.Form("FamilyName")
:   rsUsers("GivenName") = Request.Form("GivenName")
:   rsUsers("StreetAddress1") = Request.Form("Address1")
:   rsUsers("StreetAddress2") = Request.Form("Address2")
:   rsUsers("City") = Request.Form("City")
:   rsUsers("State") = Request.Form("State")
:   rsUsers("PostalCode") = Request.Form("PostalCode")
:   rsUsers("Country") = Request.Form("Country")
:   rsUsers("Active") = True
:   rsUsers("LastLogin") = Now
:   rsUsers.Update                                               ' update
: the database
:
:   Dim strName, strValue                                   ' create session
: variables
:   For each strField in rsUsers.Fields
:     strName = strField.Name
:     strValue = strField.value
:     Session(strName) = strValue
:   Next
:   Session("blnValidUser") = True            ' declare that current user is
: validated
:   Response.Redirect "MenuForRegisteredUsers.asp"
: %>


  Return to Index