Wednesday, October 7, 2009
Stored Procedure Parameter Order in ADODB Classic ASP
This absolutely matters! If you do not put your parameters in order, particularly your RETURN values have to be your first parameters added, then the program will not work properly! Put everything int he order where you declared your stored procedure.
ADODB in javascript- Stored procedure
Here is an example of calling a stored procedure (this inside a classic ASP PAGE) using javascript as your code:
var cn = Server.CreateObject("ADODB.Connection");
var cmd = Server.CreateObject("ADODB.Command");
var para = Server.CreateObject("ADODB.Parameter");
var adCmdStoredProc = 4; //set adodb enumeration value
var adVarChar = 200 ;
var adParamInput = 1 ;
cn.open("DSN", "User", "Pass");
cmd.ActiveConnection = cn;
cmd.CommandText = "procedure";
cmd.CommandType = adCmdStoredProc;
cmd.Parameters.Append(cmd.CreateParameter("@Input", adVarChar, adParamInput, 250));
cmd.Parameters("@Input") = "Input this";
cmd.Execute();
One thing to watch for when passing in a varchar input string: Please make sure when you create the parameter, that you pass in the size of the parameter in the stored procedure as the last input of creation. I had a varchar250 field in this one.
var cn = Server.CreateObject("ADODB.Connection");
var cmd = Server.CreateObject("ADODB.Command");
var para = Server.CreateObject("ADODB.Parameter");
var adCmdStoredProc = 4; //set adodb enumeration value
var adVarChar = 200 ;
var adParamInput = 1 ;
cn.open("DSN", "User", "Pass");
cmd.ActiveConnection = cn;
cmd.CommandText = "procedure";
cmd.CommandType = adCmdStoredProc;
cmd.Parameters.Append(cmd.CreateParameter("@Input", adVarChar, adParamInput, 250));
cmd.Parameters("@Input") = "Input this";
cmd.Execute();
One thing to watch for when passing in a varchar input string: Please make sure when you create the parameter, that you pass in the size of the parameter in the stored procedure as the last input of creation. I had a varchar250 field in this one.
Subscribe to:
Posts (Atom)