Problem with script based on Chap 17 p 548-9

Results 1 to 2 of 2

Thread: Problem with script based on Chap 17 p 548-9

  1. #1
    Matthew Kirwan Guest

    Default Problem with script based on Chap 17 p 548-9

    Hi,<BR><BR>I have written a script based on the script on page 548-549 (Listing 17.8). This particular script allows a user to modify the details of a one-day course (time/date/location).<BR><BR>The only difference between the script in the book and my script is that I am trying to find the record in the table via the primary key, ID rather than the user&#039s name as in the example in the book.<BR><BR>The ID of the record that is being modified is passed from a previous script (analogous to the script on p. 546-7) using a hidden field. Because of this, this value is changed from being an integer to a string. However the value it needs to be compared with is a integer. So my script (see below) needed to be modified.<BR><BR>I changed statement:<BR>If (StrComp(objRS("ID"), strID, vbTextCompare) = 0) Then<BR><BR>to<BR><BR>If (StrComp(CStr(objRS("ID")), strID, vbTextCompare) = 0) Then<BR><BR>so strings would be compared. However type coversion did not work as the line<BR><BR>isNumeric((CStr(objRS("ID")) gave a result of TRUE<BR><BR>Can you please make a suggestion on what can be done?<BR>I also tried converting strID to a integer using CInt<BR>but this type conversion did not work either<BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;!-- #include virtual="/" --&#062;<BR>&#060;!-- #include file="DatabaseConnect.asp" --&#062;<BR>&#060;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<BR> ""&#062;<BR>&#060;html&#062;<BR>&#060;head &#062;<BR>&#060;title&#062;Search Results&#060;/title&#062;<BR>&#060;link rel="stylesheet" href="safetycourse.css"&#062;<BR>&#060;/head&#062;<BR>&#060;body&#062;<BR><BR>&#060;% <BR> Dim objRS, bolFound, strID<BR> strID = Request.Form("id")<BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> objRS.Open "AvailableCourses", objConn, , adLockOptimistic, adCmdTable <BR> bolFound = False<BR><BR> Do Until objRS.EOF OR bolFound<BR> If (StrComp(objRS("ID"), strID, vbTextCompare) = 0) Then<BR> bolFound = True<BR> Else <BR> objRS.MoveNext<BR> End If<BR> Loop<BR><BR> If Not bolFound Then<BR> objRS.Close<BR> Set objRS = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR> Response.Write "&#060;a href = ""modifyCourse.html""&#062;Modified record not found&#060;/a&#062;"<BR> Response.End<BR> End If<BR><BR> objRS("UserNumber") = Request.Form("usernumber")<BR> objRS("CourseTime") = Request.Form("time")<BR> objRS("CourseDate") = Request.Form("date")<BR> objRS("MaxCapacity") = Request.Form("maxcapacity")<BR> objRS("CourseLocation") = Request.Form("location")<BR> objRS("CourseType") = Request.Form("courseType")<BR> objRS.Close<BR> Set objRS = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR>%&#062;<BR>Changes made successfully.<BR>&#060;/body&#062;<BR>&#060;/html&#062;

  2. #2
    Matthew Kirwan Guest

    Default Problem solved

    This posting was replied to in one of the other forums.<BR>Problem is now solved.<BR><BR>Regards,<BR><BR>Matthew Kirwan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts