Forums
This topic is locked
insert record not functioning?
Posted 08 Oct 2003 00:28:21
1
has voted
08 Oct 2003 00:28:21 richard thomas posted:
Hi,I have a problem I can't understand.
My page is a simple insert record to access database. (DWMX, ASP (VB)).
I have applied the server behaviour and tested on my local machine, without success. I decided to try on my remote web server, which I know is running ok (Other dynamic pages are working on same domain), but have same problem? No insert, no error messages, no redirect to the page I've specified if insert successful etc? I just click submit and the data leaves the fields, but doesn't seem to go anywhere?
I have used UltraDev since first release and not had this sort of prob before. The fact that I'm having the same prob remote and local is why I'm stumped? I have attached code and URL for info.
Anyone who can spot anything or relate to problem, much appreciated.
I have a file upload field on the form, but don't expect this would make a difference? I intend to apply a pureASP upload behaviour for this (the upload field) once I have the insert record behaviour working.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ConnPrecise.asp" -->
<%
' *** 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 <> ""

MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert"


MM_editConnection = MM_ConnPrecise_STRING
MM_editTable = "products"
MM_editRedirectUrl = "add_product_success.asp"
MM_fieldsStr = "product_name|value|product_code|value|manufacturer|value|specification|value|additonal_info|value|price|value|special_offer_price|value|special_offer|value|file|value"
MM_columnsStr = "prod_name|',none,''|prod_code|',none,''|prod_manufacturer|',none,''|prod_spec|',none,''|prod_info|',none,''|prod_price|none,none,NULL|prod_special_offer_price|none,none,NULL|prod_special_offer|none,1,0|prod_image|',none,''"
' 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 <> ""

If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""

MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert"


' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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"

MM_altVal = MM_typeArray(1)
If (MM_altVal = "none"

MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none"

If (MM_formVal = ""

MM_formVal = MM_emptyVal
Else
If (MM_altVal <> ""

MM_formVal = MM_altVal
ElseIf (MM_delim = "'"

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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & "


If (Not MM_abortEdit) Then
' execute the insert
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 <> ""

Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form ACTION="<%=MM_editAction%>" METHOD="POST" enctype="multipart/form-data" name="form1">
<table width="650" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="223"><div align="right">product name</div>
</td>
<td width="415"><label>
<input name="product_name" type="text" id="product_name" size="50">
</label></td>
</tr>
<tr>
<td><div align="right">product code/ref No</div></td>
<td><input name="product_code" type="text" id="product_code" size="50" title="Enter the products manufacturer code here, this helps visitors find the exact product they require using the search facility"></td>
</tr>
<tr>
<td><div align="right">manufacturer</div>
</td>
<td><input name="manufacturer" type="text" id="manufacturer" size="50"></td>
</tr>
<tr>
<td valign="top"><div align="right">specification</div>
</td>
<td valign="top"><textarea name="specification" cols="50" rows="5" id="specification"></textarea></td>
</tr>
<tr>
<td valign="top"><div align="right">additional info</div></td>
<td valign="top"><textarea name="additonal_info" cols="50" rows="5" id="additonal_info"></textarea></td>
</tr>
<tr>
<td><div align="right">product price</div>
</td>
<td><label>
£
<input name="price" type="text" id="price" size="10" title="Enter the products price here">
.00 </label></td>
</tr>
<tr>
<td><div align="right">special offer price</div>
</td>
<td>£
<input name="special_offer_price" type="text" id="special_offer_price" size="10" title="If this product is a special offer, enter the offer price here">
.00</td>
</tr>
<tr>
<td><div align="right">product special offer ?</div>
</td>
<td><label>
<input name="special_offer" type="checkbox" id="special_offer" value="checkbox" title="check this box if this product is under special offer, don't forget to provide a special offer price above as well.">
</label></td>
</tr>
<tr>
<td><div align="right">product image</div>
</td>
<td><label>
<input name="file" type="file" title="To include an image with this products listing, click the Browse button, find the image on your local hard drive and select it, then click Open. The image will be uploaded to the web site when you add this procuct to the database">
</label></td>
</tr>
<tr>
<td><div align="right"></div>
</td>
<td> </td>
</tr>
<tr>
<td><div align="right"></div>
</td>
<td><label>
<input type="submit" name="Submit" value="Add Product">
</label></td>
</tr>
<tr>
<td><div align="right"></div>
</td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
Referring URL 1: www.precisetrading.com/control/add_product.asp
Replies
Replied 08 Oct 2003 12:02:44
08 Oct 2003 12:02:44 richard thomas replied:
I have resolved this problem....don't ask how ??