Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Record Error

Status
Not open for further replies.

TrevorCB

Programmer
Aug 20, 2001
6
GB
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
 
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!
 
Here's the code...

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

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

' boolean to abort record edit
MM_abortEdit = false

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

If (CStr(Request(&quot;MM_update&quot;)) <> &quot;&quot; And CStr(Request(&quot;MM_recordId&quot;)) <> &quot;&quot;) Then

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

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, &quot;|&quot;)
MM_columns = Split(MM_columnsStr, &quot;|&quot;)

' 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 <> &quot;&quot; And Request.QueryString <> &quot;&quot;) Then
If (InStr(1, MM_editRedirectUrl, &quot;?&quot;, vbTextCompare) = 0 And Request.QueryString <> &quot;&quot;) Then
MM_editRedirectUrl = MM_editRedirectUrl & &quot;?&quot; & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & &quot;&&quot; & Request.QueryString
End If
End If

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

If (CStr(Request(&quot;MM_update&quot;)) <> &quot;&quot; And CStr(Request(&quot;MM_recordId&quot;)) <> &quot;&quot;) Then

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

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

If (MM_editRedirectUrl <> &quot;&quot;) Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<!--#include file=&quot;Connections/CherryDVD.asp&quot; -->
<%
Dim rsUser__MMColParam
rsUser__MMColParam = &quot;1&quot;
if (Request.QueryString(&quot;Username&quot;) <> &quot;&quot;) then rsUser__MMColParam = Request.QueryString(&quot;Username&quot;)
%>
<%
set rsUser = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsUser.ActiveConnection = MM_CherryDVD_STRING
rsUser.Source = &quot;SELECT * FROM Users WHERE Username = '&quot; + Replace(rsUser__MMColParam, &quot;'&quot;, &quot;'&quot;) + &quot;'&quot;
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 = &quot;Username&quot;
MM_paramName = &quot;Username&quot;
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> &quot;&quot;) Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> &quot;&quot;)
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=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form method=&quot;post&quot; action=&quot;<%=MM_editAction%>&quot; name=&quot;form1&quot;>
<table align=&quot;center&quot;>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Username:</td>
<td><%=(rsUser.Fields.Item(&quot;Username&quot;).Value)%></td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Password:</td>
<td>
<input type=&quot;password&quot; name=&quot;Password&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Password&quot;).Value)%>&quot; size=&quot;15&quot; maxlength=&quot;10&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Status:</td>
<td>
<input type=&quot;text&quot; name=&quot;Status&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Status&quot;).Value)%>&quot; size=&quot;10&quot; maxlength=&quot;6&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Surname:</td>
<td>
<input type=&quot;text&quot; name=&quot;Surname&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Surname&quot;).Value)%>&quot; size=&quot;35&quot; maxlength=&quot;20&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Name:</td>
<td>
<input type=&quot;text&quot; name=&quot;Name&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Name&quot;).Value)%>&quot; size=&quot;35&quot; maxlength=&quot;20&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Email:</td>
<td>
<input type=&quot;text&quot; name=&quot;Email&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Email&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Address1:</td>
<td>
<input type=&quot;text&quot; name=&quot;Address1&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Address1&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;30&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Address2:</td>
<td>
<input type=&quot;text&quot; name=&quot;Address2&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Address2&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;30&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>City:</td>
<td>
<input type=&quot;text&quot; name=&quot;City&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;City&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;30&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Country:</td>
<td>
<input type=&quot;text&quot; name=&quot;Country&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Country&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;30&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Postcode:</td>
<td>
<input type=&quot;text&quot; name=&quot;Postcode&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Postcode&quot;).Value)%>&quot; size=&quot;20&quot; maxlength=&quot;15&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;>Phone:</td>
<td>
<input type=&quot;text&quot; name=&quot;Phone&quot; value=&quot;<%=(rsUser.Fields.Item(&quot;Phone&quot;).Value)%>&quot; size=&quot;32&quot; maxlength=&quot;20&quot;>
</td>
</tr>
<tr valign=&quot;baseline&quot;>
<td nowrap align=&quot;right&quot;> </td>
<td>
<input type=&quot;submit&quot; value=&quot;Update Record&quot;>
</td>
</tr>
</table>
<input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;true&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_recordId&quot; value=&quot;<%= rsUser.Fields.Item(&quot;Username&quot;).Value %>&quot;>
</form>
<p> </p>
</body>
</html>
<%
rsUser.Close()
%>

==============================================
 
TrevorCB,

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

Say if it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top