Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

ASP/JScript ADO parameterized query

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.

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();
}

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed