Example: how to pass parameter to stored procedure and get a recordset from it:
PHP код:
static void DD_StoredProcReturnRecordsetTest(Args _args)
{
str serverName = "Server";
str baseName = "Database";
str userId = "UserId";
str userPassword = "Password";
CCADOConnection cn;
COM comCN;
COM cmd;
COM param, params;
COMVariant emptyParam;
COMVariant result;
CCADORecordset rs;
str parameter;
;
cn = new CCADOConnection();
cn.open(
"Provider=SQLOLEDB;"+
"Data Source=" + serverName + ";" +
"Initial Catalog=" + baseName + ";" +
"uid=" + userId + ";" +
"pwd=" + userPassword);
comCN = cn.connection();
cmd = new COM("ADODB.Command");
cmd.activeConnection(comCN);
cmd.commandType(1); //adCmdText, see ObjectBrowser in VBA
parameter = "Parameter value";
cmd.CommandText(strfmt("exec spTestReturnRecordset '%1'", parameter));
rs = new CCADORecordset(cmd.Execute());
while (!rs.eof())
{
info(strfmt("%1", rs.fields().itemIdx(0).value()));
rs.movenext();
}
cn.close();
}