I am defining my SQL statments as user stored procedures (usp's) in SQLServer. I normally pass parameters, eg @table_id, to and from the usp. Now, however, I want to store the results of my query in a recordset, using the following code:
var cn = new ActiveXObject("ADODB.Connection");
var rs1 = new ActiveXObject("ADODB.Recordset");
var cm = new ActiveXObject("ADODB.Command");
cm.CommandText = "dbo.usp_selectstatus";
cm.CommandType = 4;
cm.Prepared = true;
I know the problem is with the final line of code shown here, and tried to write it like
rs1 = cm.Execute();,
but the error I get is :
The application requested an operation on an object with a reference to a closed or invalid Connection object.
Can you tell me what the correct code would be to establish the connection, etc.?