Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2004, 12:07 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update Records

I tried to creqate an Update records script using Dreamweaver MX 2004 7.0.1

When I runt he code I get
     Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'LBound'
/Order_Entry/Edit.asp, line 80


Can someone please help me figure it out.. Thanks in Advanced..

Brian

Attached is the code
************************************************** ********************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i


MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

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

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
Response.Write (Cstr(Request("MM_update")))
  MM_editConnection = MM_Northcoast_STRING
  MM_editTable = "northcoast.nbs"
  MM_editColumn = "key"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "thankyou.htm"
  MM_fieldsStr = "Company|value|Status|value|ord_date|value|appr_da te|value|sales_rep|value|equip_deliv|value|equip_r epl|value|unbill_dol|value|billed_dol|value|lease_ co|value|WIP_date|value|del_date|value|bill_date|v alue|Sales_order|value|WIP_Recv|value|SS_Req|value |est_date_del|value|Comments|value|Key|value"
  MM_columnsStr = "Company|',none,''|status|',none,''|ord_date|',non e,''|appr_date|',none,''|sales_rep|',none,''|equip _deliv|',none,''|equip_repl|',none,''|unbill_dol|n one,none,NULL|billed_dol|none,none,NULL|lease_co|' ,none,''|WIP_date|',none,''|del_date|',none,''|bil l_date|',none,''|so_rec|',none,''|WIP_rec|',none,' '|ss_req|',none,''|est_date_del|',none,''|comments |',none,''|key|none,none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")

  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

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

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
Response.Write (Cstr(Request("MM_update")))
  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

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

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
Dim Edit__MMColParam
Edit__MMColParam = "1"
If (Request.Form("customer") <> "") Then
  Edit__MMColParam = Request.Form("customer")
End If
%>
<%
Dim Edit
Dim Edit_numRows

Set Edit = Server.CreateObject("ADODB.Recordset")
Edit.ActiveConnection = MM_Northcoast_STRING
Edit.Source = "SELECT * FROM northcoast.nbs WHERE cust_name = '" + Replace(Edit__MMColParam, "'", "''") + "'"
Edit.CursorType = 0
Edit.CursorLocation = 2
Edit.LockType = 1
Edit.Open()

Edit_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form action="<%=MM_editAction%>" method="POST" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td width="167" align="right" nowrap>Company:</td>
      <td width="224"><select name="Company">
          <option value="NBS" <%If (Not isNull(Edit.Fields.Item("Company").Value)) Then If ("NBS" = CStr(Edit.Fields.Item("Company").Value)) Then Response.Write("SELECTED") : Response.Write("")%>>NBS</option>
          <option value="NDI" <%If (Not isNull(Edit.Fields.Item("Company").Value)) Then If ("NDI" = CStr(Edit.Fields.Item("Company").Value)) Then Response.Write("SELECTED") : Response.Write("")%>>NDI</option>
        </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Status:</td>
      <td><select name="Status" id="Status">
        <option value="Awaiting Setup">Awaiting Setup</option>
        <option value="In Setup">In Setup</option>
        <option value="Awaiting Invoice">Awaiting Invoice</option>
        <option value="Complete">Complete</option>
        <option value="To be funded">To be funded</option>
        <option value="Additional Info. Needed">Additional Info. Needed</option>
        <option value="On Order">On Order</option>
        <option value="Funded">Funded</option>
            </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Order Date :</td>
      <td><input type="text" name="ord_date" value="<%=(Edit.Fields.Item("ord_date").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Approval Date :</td>
      <td><input type="text" name="appr_date" value="<%=(Edit.Fields.Item("appr_date").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Sales Rep:</td>
      <td><input type="text" name="sales_rep" value="<%=(Edit.Fields.Item("sales_rep").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Equipment Delivered :</td>
      <td><input type="text" name="equip_deliv" value="<%=(Edit.Fields.Item("equip_deliv").Value)% >" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Equipment Replaced::</td>
      <td><input type="text" name="equip_repl" value="<%=(Edit.Fields.Item("equip_repl").Value)%> " size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Unbilled Dollars:</td>
      <td><input type="text" name="unbill_dol" value="<%=(Edit.Fields.Item("unbill_dol").Value)%> " size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Billed Dollars: :</td>
      <td><input type="text" name="billed_dol" value="<%=(Edit.Fields.Item("billed_dol").Value)%> " size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Lease Company/Cash:</td>
      <td><input type="text" name="lease_co" value="<%=(Edit.Fields.Item("lease_co").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">WIP Date:</td>
      <td><input type="text" name="WIP_date" value="<%=(Edit.Fields.Item("WIP_date").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Delivery Date :</td>
      <td><input type="text" name="del_date" value="<%=(Edit.Fields.Item("del_date").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">BIlling Date :</td>
      <td><input type="text" name="bill_date" value="<%=(Edit.Fields.Item("bill_date").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Sales Order Received :</td>
      <td><p>
        <label>
        <input type="radio" name="Sales_order" value="Yes">
  Yes</label>
        <br>
        <label>
        <input type="radio" name="Sales_order" value="No">
  No</label>
</p></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">WIP Received:</td>
      <td><p>
        <label>
        <input type="radio" name="WIP_Recv" value="Yes">
  Yes</label>
        <br>
        <label>
        <input type="radio" name="WIP_Recv" value="No">
  No</label>
      </p></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Site Survey Required:</td>
      <td><p>
        <label>
        <input type="radio" name="SS_Req" value="Yes">
  Yes</label>
        <br>
        <label>
        <input type="radio" name="SS_Req" value="No">
  No</label>
        <br>
      </p></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Estimated Delivery Date:</td>
      <td><input type="text" name="est_date_del" value="<%=(Edit.Fields.Item("est_date_del").Value) %>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Comments</td>
      <td><textarea name="Comments" cols="32" rows="4" id="Comments"><%=(Edit.Fields.Item("comments").Val ue)%></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Update record"></td>
    </tr>
  </table>

<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Edit.Fields.Item("key").Value %>">
  <input type="hidden" name="MM_update" value="Update">
<input type="hidden" name="MM_recordId" value="<%= Edit.Fields.Item("key").Value %>">
  <input name="Key" type="hidden" id="Key" value="<%=(Edit.Fields.Item("key").Value)%>">
</form>
<p>&nbsp;</p>
</body>
</html>
<%
Edit.Close()
Set Edit = Nothing
%>
************************************************** ********************

Reply With Quote
  #2 (permalink)  
Old October 4th, 2004, 01:53 PM
Imar's Avatar
Wrox Author
Points: 72,035, Level: 100
Points: 72,035, Level: 100 Points: 72,035, Level: 100 Points: 72,035, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,079
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

That's an awful lot of code to digest and search for an error.

My guess, without looking at the code too much, is that your SELECT statement is't aligned correctly. So, fieldsStr and MM_columnsStr may have a different length. Did you manually change one of these variables?

Just a guess though; it would have helped if you'd indicated what line 80 was so I could have taken a more detailed look.

Cheers,

Imar
Reply With Quote
  #3 (permalink)  
Old October 5th, 2004, 08:39 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry Her is the code for Line 80

' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 <<< Line 80
Reply With Quote
  #4 (permalink)  
Old October 5th, 2004, 02:14 PM
Imar's Avatar
Wrox Author
Points: 72,035, Level: 100
Points: 72,035, Level: 100 Points: 72,035, Level: 100 Points: 72,035, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,079
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, I see.

Did you manually change the values of MM_columnsStr or MM_fieldsStr?

Apparently, one of the two arrays derived from these strings is bigger than the other, causing this error.

Did you try to recreate the Server Behavior by opening it from the Server Behaviors panel?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old October 5th, 2004, 02:31 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No I have not Made any changes to it.

I did make Hidden fields so that people can not update the Key value and cust_name fileds..

But I have tried the basic right out of the box code from Dreamweaver.

I just tried to re-create through server behaviors.


Reply With Quote
  #6 (permalink)  
Old October 5th, 2004, 03:05 PM
Imar's Avatar
Wrox Author
Points: 72,035, Level: 100
Points: 72,035, Level: 100 Points: 72,035, Level: 100 Points: 72,035, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,079
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It's weird.

The code splits up MM_fieldsStr based on the | character in the string.

It then loops stepping through the array derived from it, two steps at the time. This is done to retrieve the column names, and skip the "value" values. Since each column name is followed by the text value, I think this should work.

If I were you, I'd use Response.Write(UBound(MM_fields)) and Response.Write(UBound(MM_columns)) to see if you can find anything odd in these arrays.

Other than that, it's hard for me to fix this problem as I cannot run your page and see for myself.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UpDate Records on a Form ManFriday Access 2 September 8th, 2007 04:21 AM
UPDATE RECORDS!!! a_pathak BOOK: Beginning ASP 3.0 1 March 3rd, 2004 04:00 AM
update records error damnnono_86 Access 1 January 28th, 2004 03:22 PM
Help! Cannot update records mcalder Classic ASP Databases 6 August 14th, 2003 01:54 PM
update records by the loop mateenmohd SQL Server 2000 2 July 16th, 2003 06:38 AM



All times are GMT -4. The time now is 03:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.