Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once you've created your database through SQL Server Management Studio, you're then ready to work with it from within Visual Web Developer 2008. Open Visual Web Developer and then create a brand-new website. You can create it anywhere on disk. I'm going to create it under my Exercise files area. From the menu, select File > New Web Site. Select ASP.NET Web Site from the templates list and then set the website location. I'll create a new website called SQL Server, under the Exercise files, Ch02SQLServer folder. The language can be either Visual C# or Visual Basic for this exercise. Click OK to create the brand-new website. As with all brand-new websites, you'll have a single file called Default.aspx, which has an associated file with either a .cs or a .vb extension that contains the page's code. Now, to connect to your database, go to the Database Explorer window. By default, this appears on the right side, in the tabs associated with the Solution Explorer. Then go to the toolbar and click the button labeled Connect to Database.
You can also right-click on Data Connections and select Add Connection from there. Either way, you'll go to the Add Connection dialog box. You can click the Refresh button and try to connect to your database automatically, but you might find from within Visual Web Developer that all you see is the name of your computer. Notice that if I pull down the list, I see DAVIDMBPRO, which is the name of my computer. Instead, you'll want to type in the server name and the SQL Server instance manually and use localhost rather than your actual computer name to make the database connection more portable between computers. I'll type in localhost\. Make sure you're using the backslash and not the forward slash And then the SQL Server instance name, which is sqlexpress. Notice this time that I'm typing it in in all lowercase. The instance name is not case- sensitive. Next you'll indicate whether you are using Windows authentication or SQL Server authentication. If your copy of SQL Server is on your own computer, as is the case here, you can use Windows authentication. If you're working with an SQL Server installation on another system, such as an SQL Server database that's rented from an Internet service provider, you'll need to use SQL Server authentication and pass in your username and your password. I'll use Windows authentication. At this point, you should be able to see a list of the databases that are available through your copy of SQL Server. Go down to the label Select or enter a database name and click the arrow to see a list of available databases. And there's the database that I've already created called mybookstore.
Now, if you don't see that database listed, you should go back to the previous videos in this chapter and follow the directions to create the database. If you do see the database though, select it. Now click the Test Connection button and you should see the dialog box indicating that the test succeeded and that you're connected to the database. Click OK to clear the dialog. Then click OK to save your database connection configuration. From within the Database Explorer, you can take a look at the structure of your database. Now here's a little tip about working with the panels on the right side of the Visual Web Developer interface. Notice that on my screen, which has a resolution of 1024x768, the amount of visual space I have to work in is fairly limited. You can improve that situation by reconfiguring the panels on the right so that they slide out in the same way as the panels on the left. The easiest way to do this is to go to the menu and select Window > Auto Hide All.
Notice that all the panels on the right are now turned into tabbed panels, just like the ones on the left. You can now move the cursor over the appropriate tabs, such as the Database Explorer, and then you'll have a lot more vertical space to work with. And if you like, you can even drag out the width of that panel, and now you can see everything you need to see. I'll open up my connection and I'll show you that it has the list of tables. I'll open up the table list and there are the four tables that are available in the database: Authors, Publishers, Titles, and Users. From the Database Explorer, you can right-click and select Show Table Data and Visual Web Developer will query the database table and show you the results.
Close that window and then move the cursor over the tab again. You'll see the Database Explorer slide out. Then go to the Authors Table again, right-click, and select Open Table Definition. In Visual Web Developer, you can actually manage your SQL Server table structure in the same way as you can in SQL Server Management Studio. You can add columns, change column properties, and again do everything that you can in the Studio interface. The only thing that was important to do in SQL Server Management Studio itself was to actually create the database, but then once it's created, you can do everything else from within Visual Web Developer. Finally, I'll go back to the Database Explorer one more time and show that there are many more categories that you can create. For example, you can go to the Views and create prebuilt queries. You can use stored procedures, functions, and everything else that's available in SQL Server 2008.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101058 Viewers
61 Video lessons · 87839 Viewers
71 Video lessons · 71720 Viewers
56 Video lessons · 103597 Viewers
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.
Your file was successfully uploaded.