Wednesday, March 7, 2012

Recordset + StoredProcedure ?

I use a recordset for a report

Is a difference between?

1) To use a stored procedure => return a record set

cmd.CommandText = "StoredProcedureName"
cmd.CommandType = adCmdStoredProc
cmd.Execute

Or

2) rs.Open SELECT * FROM , cn, adOpenStatic, adLockReadOnly

__________________________
cn is ADO connection string
cmd is ADO command
rs is ADO RecordsetThe Strore procedure was compiled so is fastest. If the execution plan is still in memory they have not waiting time.

and for the support of your Application if you use at different place your query... with sprocs you need to make de change at only one place... ;)|||Originally posted by Franky
The Strore procedure was compiled so is fastest. If the execution plan is still in memory they have not waiting time.



As regarding the execution plan being stored in Memory .. SQL 2000 also stores the exec plans of all the queries and ages them according to a certain algorithm. So there is really not much difference in that regard.|||and for the support of your Application if you use at different place your query... with sprocs you need to make de change at only one place...

Additionally it is a lot easier to change the stored procedure later on then to change the sql inside your app which would have to be re-compiled and redistributed...|||Originally posted by Ovidiu
I use a recordset for a report

Is a difference between?

1) To use a stored procedure => return a record set

cmd.CommandText = "StoredProcedureName"
cmd.CommandType = adCmdStoredProc
cmd.Execute

Or

2) rs.Open SELECT * FROM ?? cn, adOpenStatic, adLockReadOnly

__________________________
cn is ADO connection string
cmd is ADO command
rs is ADO Recordset

Hi,
I got the experience of this kind of executing a stored procedure and returning a recordset in ASP and VB.
Maybe you can try add this before your last line.
set rs1 = cmd.execute
Then the rs1 is what you want to process next step.
Good lucks

Mosu

No comments:

Post a Comment