Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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.
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.
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 to use that connection. In this interface, it's asking me if I'd like to use a table or a custom stored procedure. 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. We just created getActiveAuthors. That's the one I want. We can hit a test, return some data and that certainly looks like the accurate data 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 and we have got a list of all of our active authors successfully. We connected that stored procedure to our website, didn't actually write any code 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, so the 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.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.