I am working on a school front-end system called iSAMS, which uses classic asp, using SQL Server 2008 R2.
In the simplest terms, my main asp page (viewstudent-edit-test.asp) returns and displays two fields from a database table : txtCommentID (the Report ID) and txtComment (the actual report). It looks something like this :
ReportID Report
-------- ------
32 Good progress, now please edit me ...
I (or the user) need to be able to edit the data in the Report column, and at the moment, when the Report field is clicked on, the text becomes editable.
when the "Submit" button is clicked, it fires off another page called updateform.asp, and this is where the problem is.
It returns the error on updateform.asp :
Error page: /legacy/custommodules/ucasreports/updateform.asp
Error category: adodb.command
Error type: arguments are of the wrong type, are out of acceptable range,
or are in conflict with one another.
Error source:
Error line: 9
...and the line 9 is in updateform.asp (1st sqlProp.Parameters line):
<!--#INCLUDE FILE="ACN.asp"-->
<%
getConID = request.form("ID")
getCom = request.form("Comment")
Set sqlProp=Server.CreateObject("ADODB.Command")
sqlProp.ActiveConnection=Conn
sqlProp.commandtext="update CAN_Tbl_UCAS_Reports set txtComment=? where
txtCommentID=?"
'--------------
sqlProp.Parameters.Append sqlProp.CreateParameter("@txtComment", adVarChar,
adParamInput, 3500, getCom)
'--------------
sqlProp.Parameters.Append sqlProp.CreateParameter("@txtCommentID",
adInteger, adParamInput, , getConID)
sqlProp.Execute
%>
My original page code which displays the data : (viewstudent-edit-test.asp) :
sql = "SELECT DISTINCT txtSchoolID, txtID, SubjectTeacher, txtCommentID,
txtComment FROM CAN_Tbl_UCAS_Reports WHERE intReportType = 1 AND
txtSchoolID = " & paramBuilder.NextParameter(intID) & " ORDER BY txtID"
Set rsRecord = Database.GetRs(sql, conn, paramBuilder.Parameters)
if not rsRecord.EOF then
do until rsRecord.EOF
'First we need to create our Variables
ConID = rsRecord("txtCommentID")
Com = rsRecord("txtComment")
%>
<tr>
<td style="text-align:center"><%Response.Write(rsRecord.Fields
("txtCommentID").value)%></td>
<td><%Response.Write(rsRecord.Fields("txtComment").value)%></td>
<td style="text-align:center">
<form action="updateform.asp" method="post">
<input type="text" name="ID" value="<%=ConID%>" />
<textarea rows="10" cols="50" name="Comment"><%=Com%></textarea>
<input type="submit" name="Submit" value="Subsdfmit" />
</form>
</td>
</tr>
<%
rsRecord.Movenext
loop
end if
rsRecord.close
set rsRecord = nothing
%>
Finally, my connection string file, ACN.asp :
<%
Dim Conn
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=SQLOLEDB;Data
Source=sourcebob;UID=userbob;PWD=passwordbob;DATABASE=iBOB;"
Conn.Open
%>
I have checked the type and order of the parameters, and they seem to be OK. Googling the error message points to a missing connection string, but that is not the problem. It seems there are many examples of forms where user input is accepted, but not how to successfully edit pre-existing data.
Apologies for so much code, but I thought it was need in order to analyse the problem. Any ideas are much appreciated! Thanks.