
Jun 3rd, 2007, 06:56
|
|
Junior Member
|
|
Join Date: Feb 2007
Location: Crowborough UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Updating a record
Hi I am new to ASP and have a problem updating a record in my db.
The error is:
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
And the code is:
- Code: Select all
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="sqlconn.asp"-->
<%
'Constants ripped from adovbs.inc:
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
dim strSearchStudId
dim strSearchSurname
dim strSearchForename
dim strSQL
'populate variables if anything was passed from the submitted form
strSearchStudId = Request.QueryString("id")
strSearchSurname = Request.QueryString("surname")
strSearchForename = Request.QueryString("forename")
'Create connection object
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open conn2
'Get setup table information
strSQL = "SELECT * FROM setup"
Set rsSetup = Server.CreateObject("ADODB.Recordset")
rsSetup.Open strSQL, cn, 1, 3, adCmdText
if request.QueryString("action") = "add" then
'Handle any additions/edits before populating the grid
if request.form("DoSubmit") = "True" and request.Form("num_student_college_sub_total") > 0 then
strSQL = "INSERT INTO paymentAdd " & _
"(student_id, acadyear, tuition, collegetotalpay, collegetotal, added, who_added, updated, who_updated) " & _
"VALUES (" & _
"'" & Request.QueryString("id") & "', '" & _
rsSetup("acadyear") & "', " & _
FormatCurrency(request.Form("num_tuition")) & ", '" & _
request.Form("college_total") & "', " & _
FormatCurrency(request.Form("num_student_college_sub_total")) & ", " & _
"Convert(DateTime, GETDATE(), 103), " & _
"'" & session("Name") & "', " & _
"Convert(DateTime, GETDATE(), 103), " & _
"'" & session("Name") & "');"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, cn, 1, 3, adCmdText
end if
end if
if request.QueryString("action") = "release" then
strSQL = "UPDATE paymentAdd Set " & _
"collegetotalpay" = "Yes" & " , " &_
"WHERE id= '" & request.QueryString("rid") & "' AND student_id = '" & request.QueryString("id") & "';"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, cn, 1, 3, adCmdText
end if
if request.QueryString("action") = "delete" then
strSQL = "DELETE FROM paymentAdd WHERE id = '" & request.QueryString("rid") & "';"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, cn, 1, 3, adCmdText
end if
response.Redirect("payment_scheduleAdditionsSimple.asp?id=" & strSearchStudId & "&surname=" & strSearchSurname & "&forename=" & strSearchForename)
%>
I am not sure but do I have to first loop through checking for a record in order to do an update - could that be why it is not working?
Many thanks for any help.
Last edited by Wheatus7; Jun 3rd, 2007 at 07:13.
Reason: Want to put the code in a separate window
|