ASP/JScript ADO parameterized query.
use like:
var rs = executeQuery(conn, "SELECT custid, custname FROM customers WHERE somefield > ?", [someValue]);
where conn is a "ADODB.Connection"
Requires that you first include the "adojavas.inc" include file to get definitions for the adXXX constants.
use like:
var rs = executeQuery(conn, "SELECT custid, custname FROM customers WHERE somefield > ?", [someValue]);
where conn is a "ADODB.Connection"
Requires that you first include the "adojavas.inc" include file to get definitions for the adXXX constants.
function executeQuery(conn, qry, params) { if (arguments.length == 2) { params = []; } var cmd, i; cmd = Server.CreateObject("ADODB.Command"); cmd.CommandText = qry; cmd.CommandType = adCmdText; for (i = 0; i < params.length; i++) { cmd.Parameters.Append(cmd.CreateParameter("", adVariant, adParamInput, 0, params[i])); } cmd.ActiveConnection = conn; return cmd.Execute(); }