Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Different ways of calling SP’s
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Different ways of calling SP’s

 Post Reply Post Reply
Author
Vintious View Drop Down
Newbie
Newbie
Avatar

Joined: 08 June 2002
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote Vintious Quote  Post ReplyReply Direct Link To This Post Topic: Different ways of calling SP’s
    Posted: 18 February 2003 at 8:22pm

I don't know if this should go in the database forum, but here goes.

I have an SQL 2000 database running. I am using ASP scripts to grab, update, insert, delete, etc... information from the database.

Now, I have seen two different ways of calling the stored proceedures from a database.

Let's assume that I have a database connection called "Connection" and I have declared a variable called "rst" (for my recordset).

Set rst = Connection.Execute("EXECUTE sp_name")

OR

Set rst = Server.CreateObject("ADODB.RecordSet")
rst.open "EXECUTE sp_name",Connection,3,3

Now, it would appear to me that the first way is better. First of all, you save yourself a line, and I found out I can also run another SELECT query using the same variable without having to close and Re-Set the recordset variable.

So, which way is:

  • Faster
  • Least resource intensive
  • Is the best choice??

If I'm missing something (like the way I like is really slow or something) please tell me. I'm building a large database application that I'm sure a lot of people are going to be using. I want as many optimizations as possible.

Thanks,
Vintious

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 19 February 2003 at 8:27am
You're missing something...

the first method doesn't allow you to do any kinda of "client" recordset stuff.. such as:
- Grabbing the # of records returned
- Paging
- stuff like that

Best way to show the differences is with examples, so i'll take a few minutes to do so....

For this example, let's say i have a table called "Account" that had Three columns, UserID (primary key), Username (varchar), and Password (varchar)

So if i simply wanted to insert a new record, i might have the following set up
SPROC "sp_INSER_NEW":
CREATE PROCEDURE [dbo].[sg_INSERT_NEW]
    @uname varchar(50), @pass varchar(50)
AS
INSERT INTO Account (Username, Password) VALUES (@uname,@pass)
GO


now in ASP, i could simply use:
strSQL = "sp_INSERT_NEW '" & entered uname & "', '" & entered pass & "'"
Connection.execute(strSQL)


didn't even have to make any reference to a recordset (and the above would go for updates to)

Say i wanted a list of all accounts, simply saying:
Set rst = Connection.Execute(PROC that gets full list)

would indeed work and i would have a recordset populated with all accounts... BUT if you wanted to know how many records were pulled back (using the rst.RecordCount method), if you don't create the Recordset object explicitly, you will get "-1" everytime for that

As for speed and time of execution, there will be differences, but nothing that you'd really "see".. it's all a matter of how much information you need from the recordset
Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.