Video: Executing a stored procedure

Now I'd like to go ahead and implement the functionality that will call a stored procedure and display data on the screen. Here we can see we have a space available for a list of active authors. So first let's write a stored procedure that returns all the active authors and then we'll connect that to the web page. I have some code prepared in the exercise files. And it's a very simple stored procedure that selects store from the Authors table where Active equals 1. So that would be all of our active authors. That looks good! Going back to Visual Studio, I'll insert my cursor into the appropriate table cell, and off the toolbox I want find the Data section.

This course investigates several key database-programming concepts: triggers, stored procedures, functions, and .NET CLR (Common Language Runtime) assemblies. Author Martin Guidry shows how to combine these techniques and create a high-quality database using Microsoft SQL Server 2012. The course also covers real-world uses of the INSERT, UPDATE, and DELETE procedures, and how to build a basic web form to connect to your database.

Executing a stored procedure

Now I'd like to go ahead and implement the functionality that will call astored procedure and display data on the screen.Here we can see we have a space available for a list of active authors.So first let's write a stored procedure that returns all the active authors andthen we'll connect that to the web page.I have some code prepared in the exercise files.And it's a very simple stored procedure that selects store from the Authorstable where Active equals 1. So that would be all of our active authors. That looks good!Going back to Visual Studio, I'll insert my cursor into the appropriate tablecell, and off the toolbox I want find the Data section.

So I'll scroll down a little and underneath the Data section there is a GridView.I'll drag our GridView over and it's asking me a few questions; one of them,what is my Data Source, and currently it's None.I'll create a new Data Source.I want that to be a SQL Server data source.We created the connection a few videos back, so now we have the option touse that connection.In this interface, it's asking me if I'd like to use a table or a custom storedprocedure. I'd like to use a custom stored procedure.

Then I'll hit next, and this one is asking me the name of my stored procedure. Wejust created getActiveAuthors. That's the one I want.We can hit a test, return some data and that certainly looks like the accuratedata we were hoping for.So I'll hit Finish. We're now ready to test this.So I'll go ahead and start debugging, and look at that! We've got a web page andwe have got a list of all of our active authors successfully.We connected that stored procedure to our website, didn't actually write anycode in the website just yet. We will be getting into that a few sections down the road.

But for now it's just a matter of click and drag and setting a few parameters, sothe bulk of the work was the original setup of the stored procedure.

There are currently no FAQs about SQL Server: Triggers, Stored Procedures, and Functions.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Already a member ?

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships.
Learn more

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.