Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordSet Question 1

Status
Not open for further replies.

contra

Technical User
Jun 3, 2002
1
CA
Hi everybody!

I have here a small dilema.
I try to run a stored procedure from the command object and return a recordset. Everything works fine. After that with the recordset.recordcount method I need to return the nr of records.

set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = "Provider=SQLOLEDB;Server=local;Database=INTRA;UID=sa;PWD="
cmd.CommandText = "sp_inventory"
cmd.CommandType = 4
cmd.Parameters.Append cmd.CreateParameter("@clickclass",129,1,2,"AC")
Set objRS = cmd.Execute

But because the rcordset is forwardonly and readonly the recordcount will return -1. How can I declare the type of cursor, cursor location, etc for this recordset in this code so that I can return the number of records?

Thanks a lot,
Contra
 
I haven't done it with the command object, so I don't know. But if you could change it, something like this might work:
Code:
set conn= <your connection string>
set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)

sql=&quot;sp_inventory &quot; & parameter1 & &quot;, &quot; & parameter2

rs.CursorLocation = adUseClient '=3
rs.CursorType = adOpenStatic '=3
rs.LockType = adLockBatchOptimistic '=4

rs.Open sql, conn

Hope this helps,
Palooka
 
Check out this example!

set cn = Server.CreateObject(&quot;ADODB.Connection&quot;)
set cmd = Server.CreateObject(&quot;ADODB.Command&quot;)
set objrs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
cn.CursorLocation = adUseClient
cn.Open &quot;Provider=SQLOLEDB;Server=local;Database=INTRA;UID=sa;PWD=&quot;
set cmd.ActiveConnection = cn
cmd.CommandText = &quot;sp_inventory_Class_click&quot;
cmd.CommandType = 4
cmd.Parameters.Append cmd.CreateParameter(&quot;@clickclass&quot;,adChar,adParamInput,2, Label)
cmd.Parameters.Append cmd.CreateParameter(&quot;@countnr&quot;,adInteger,adParamOutput)
set objrs = cmd.Execute

regards,
durug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top