0

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.

user692942
  • 16,398
  • 7
  • 76
  • 175
Jim
  • 17
  • 4
  • 2
    If you want to use ADODB Named Constants you have to either declare them *(include the common `adovbs.asp`)* or in your `global.asa` file *(which will be located in the ASP Web Application root folder)* add a [`METADATA` declaration](http://stackoverflow.com/a/35530750/692942) to allow the type library to be automatically available to any page inside the ASP Web Application. – user692942 May 09 '17 at 10:48
  • Thanks, Lankymart. After adding an include statement for the file adovbs_inc, asp, everything worked fine. The content of this fie can be found here : http://www.4guysfromrolla.com/webtech/code/adovbs.txt – Jim May 11 '17 at 13:10
  • You are better off using the [`METADATA` method](http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2F110199-1.shtml), it doesn't require being added via an `#include` and if added to the `global.asa` inside a ASP Web Application it applies to all pages. – user692942 May 11 '17 at 17:08
  • Thanks again, Lankymart. Sorry for the delay in replying - for some reason I have only just got your notification. – Jim May 24 '17 at 10:24

0 Answers0