R
Roy Adams
Hi group I'm having trouble using the replace command
Here's my code below
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/conn.asp" -->
<%
if( String(Request.Form("ProductName")) != "undefined" ){//formfield
is not empty
var NavID = 1;
var ProductName = String(Request.Form("ProductName"));
var Price = String(Request.Form("Price"));
var Descript = String(Request.Form("Description"));
var ProductCode = String(Request.Form("ProductCode"));
//get the form fields and put into vars
var TableFields = "ProductName,Price,Description,NavID,ProductCode";
var FormFields = "'" + ProductName + "','" + Price + "','" + Descript
+ "','" + NavID + "','" + ProductCode+"'" ;
/// it works ok if i remove the replace
FormFields=FormFields.replace("'", "''");
conn = Server.CreateObject('ADODB.Command');
conn.ActiveConnection = conn_STRING;
conn.CommandText = ("insert into products ("+ TableFields +") values
('" + FormFields + ")" );
conn.Execute();
conn.ActiveConnection.Close();
}
%>
any suggestions?
Here's my code below
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/conn.asp" -->
<%
if( String(Request.Form("ProductName")) != "undefined" ){//formfield
is not empty
var NavID = 1;
var ProductName = String(Request.Form("ProductName"));
var Price = String(Request.Form("Price"));
var Descript = String(Request.Form("Description"));
var ProductCode = String(Request.Form("ProductCode"));
//get the form fields and put into vars
var TableFields = "ProductName,Price,Description,NavID,ProductCode";
var FormFields = "'" + ProductName + "','" + Price + "','" + Descript
+ "','" + NavID + "','" + ProductCode+"'" ;
/// it works ok if i remove the replace
FormFields=FormFields.replace("'", "''");
conn = Server.CreateObject('ADODB.Command');
conn.ActiveConnection = conn_STRING;
conn.CommandText = ("insert into products ("+ TableFields +") values
('" + FormFields + ")" );
conn.Execute();
conn.ActiveConnection.Close();
}
%>
any suggestions?