Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I wish I knew about this site years ago. It would have saved me a lot of heartaches..."

Geography

Where in the world do Tek-Tips members come from?
TrevorCB (Programmer)
28 Aug 01 4:41
I get this error EVERY TIME (it's starting to get REALLY annoying!) I try to update a record in an access database.

I'm simply using one of the live form objects to update this record.

This is the error I get.
===========================================================
ADODB.Command error '800a0bb9'

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

/asp/cherrydvd/admin_user_edit.asp, line 106
===========================================================

Is there something blatently wrong / out of place that I need to do?

Thanks
Trevor
EugenePaliev (Programmer)
28 Aug 01 5:58
Hello TrevorCB!

There is defenitely an error in your script. Can you show us the code so we can see where the problem is?

Good Luck!
TrevorCB (Programmer)
28 Aug 01 6:26
Here's the code...

==============================================
<%@LANGUAGE="VBSCRIPT"%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="Admin"
MM_authFailedURL="user_login_fail.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>
<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_CherryDVD_STRING
  MM_editTable = "Users"
  MM_editColumn = "Username"
  MM_recordId = "'" + Request.Form("MM_recordId") + "'"
  MM_editRedirectUrl = "admin_user_detail.asp"
  MM_fieldsStr  = "Password|value|Status|value|Surname|value|Name|value|Email|value|Address1|value|Address2|value|City|value|Country|value|Postcode|value|Phone|value"
  MM_columnsStr = "Password|',none,''|Status|',none,''|Surname|',none,''|Name|',none,''|Email|',none,''|Address1|',none,''|Address2|',none,''|City|',none,''|Country|',none,''|Postcode|',none,''|Phone|',none,''"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<!--#include file="Connections/CherryDVD.asp" -->
<%
Dim rsUser__MMColParam
rsUser__MMColParam = "1"
if (Request.QueryString("Username") <> "") then rsUser__MMColParam = Request.QueryString("Username")
%>
<%
set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.ActiveConnection = MM_CherryDVD_STRING
rsUser.Source = "SELECT * FROM Users WHERE Username = '" + Replace(rsUser__MMColParam, "'", "'") + "'"
rsUser.CursorType = 0
rsUser.CursorLocation = 2
rsUser.LockType = 3
rsUser.Open()
rsUser_numRows = 0
%>
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
rsUser_total = rsUser.RecordCount

' set the number of rows displayed on this page
If (rsUser_numRows < 0) Then
  rsUser_numRows = rsUser_total
Elseif (rsUser_numRows = 0) Then
  rsUser_numRows = 1
End If

' set the first and last displayed record
rsUser_first = 1
rsUser_last  = rsUser_first + rsUser_numRows - 1

' if we have the correct record count, check the other stats
If (rsUser_total <> -1) Then
  If (rsUser_first > rsUser_total) Then rsUser_first = rsUser_total
  If (rsUser_last > rsUser_total) Then rsUser_last = rsUser_total
  If (rsUser_numRows > rsUser_total) Then rsUser_numRows = rsUser_total
End If
%>
<%
' *** Move To Record and Go To Record: declare variables

Set MM_rs    = rsUser
MM_rsCount   = rsUser_total
MM_size      = rsUser_numRows
MM_uniqueCol = "Username"
MM_paramName = "Username"
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Specific Record: handle detail parameter

If (MM_paramIsDefined And MM_rsCount <> 0) Then

  ' get the value of the parameter
  param = Request.QueryString(MM_paramName)

  ' find the record with the unique column value equal to the parameter value
  MM_offset = 0
  Do While (Not MM_rs.EOF)
    If (Cstr(MM_rs.Fields.Item(MM_uniqueCol).Value) = param) Then
      Exit Do
    End If
    MM_offset = MM_offset + 1
    MM_rs.MoveNext
  Loop

  ' if not found, set the number of records and reset the cursor
  If (MM_rs.EOF) Then
    If (MM_rsCount < 0) Then MM_rsCount = MM_offset
    If (MM_size < 0 Or MM_size > MM_offset) Then MM_size = MM_offset
    MM_offset = 0

    ' reset the cursor to the beginning
    If (MM_rs.CursorType > 0) Then
      MM_rs.MoveFirst
    Else
      MM_rs.Close
      MM_rs.Open
    End If
  End If

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  i = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or i < MM_offset + MM_size))
    MM_rs.MoveNext
    i = i + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = i
    If (MM_size < 0 Or MM_size > MM_rsCount) Then MM_size = MM_rsCount
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  i = 0
  While (Not MM_rs.EOF And i < MM_offset)
    MM_rs.MoveNext
    i = i + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
rsUser_first = MM_offset + 1
rsUser_last  = MM_offset + MM_size
If (MM_rsCount <> -1) Then
  If (rsUser_first > MM_rsCount) Then rsUser_first = MM_rsCount
  If (rsUser_last > MM_rsCount) Then rsUser_last = MM_rsCount
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<html>
<head>
<title>CherryDVD User Edit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="<%=MM_editAction%>" name="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Username:</td>
      <td><%=(rsUser.Fields.Item("Username").Value)%></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Password:</td>
      <td>
        <input type="password" name="Password" value="<%=(rsUser.Fields.Item("Password").Value)%>" size="15" maxlength="10">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Status:</td>
      <td>
        <input type="text" name="Status" value="<%=(rsUser.Fields.Item("Status").Value)%>" size="10" maxlength="6">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Surname:</td>
      <td>
        <input type="text" name="Surname" value="<%=(rsUser.Fields.Item("Surname").Value)%>" size="35" maxlength="20">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Name:</td>
      <td>
        <input type="text" name="Name" value="<%=(rsUser.Fields.Item("Name").Value)%>" size="35" maxlength="20">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Email:</td>
      <td>
        <input type="text" name="Email" value="<%=(rsUser.Fields.Item("Email").Value)%>" size="32" maxlength="50">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address1:</td>
      <td>
        <input type="text" name="Address1" value="<%=(rsUser.Fields.Item("Address1").Value)%>" size="32" maxlength="30">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Address2:</td>
      <td>
        <input type="text" name="Address2" value="<%=(rsUser.Fields.Item("Address2").Value)%>" size="32" maxlength="30">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">City:</td>
      <td>
        <input type="text" name="City" value="<%=(rsUser.Fields.Item("City").Value)%>" size="32" maxlength="30">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Country:</td>
      <td>
        <input type="text" name="Country" value="<%=(rsUser.Fields.Item("Country").Value)%>" size="32" maxlength="30">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Postcode:</td>
      <td>
        <input type="text" name="Postcode" value="<%=(rsUser.Fields.Item("Postcode").Value)%>" size="20" maxlength="15">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Phone:</td>
      <td>
        <input type="text" name="Phone" value="<%=(rsUser.Fields.Item("Phone").Value)%>" size="32" maxlength="20">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right"> </td>
      <td>
        <input type="submit" value="Update Record">
      </td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="true">
  <input type="hidden" name="MM_recordId" value="<%= rsUser.Fields.Item("Username").Value %>">
</form>
<p> </p>
</body>
</html>
<%
rsUser.Close()
%>

==============================================
EugenePaliev (Programmer)
28 Aug 01 6:47
TrevorCB,

First thing that I see - move include file (< ! - - # include file="Connections/CherryDVD.asp" - -  >) at the top of your page (second line).

Say if it works.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close