 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 4th, 2004, 12:07 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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"> </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> </p>
</body>
</html>
<%
Edit.Close()
Set Edit = Nothing
%>
************************************************** ********************
|
|

October 4th, 2004, 01:53 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

October 5th, 2004, 08:39 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 5th, 2004, 02:14 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

October 5th, 2004, 02:31 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

October 5th, 2004, 03:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|
 |