Part 1 of 2 Creating SQL Database and Binding to GridView Web Application with SQL ASP.Net 2.0 – Visual Studio 2005 CSE686 – Internet Programming Instructor: James W. Fawcett TA: Murat K. Gungor Summer 2006 Part 1 of 2 Creating SQL Database and Binding to GridView
Create – New - Web Site MS Visual Studio 2005
Empty Web Site – C# Name it OnlinePhoneBook
Add New Web Form
Test your empty web site Hit Ctrl+F5 to make sure it runs Set Default.aspx “As Start Page”
Add SQL Server Database File Using Server Explorer Add SQL Server Database File
PhoneBookDB.mdf will be created for us Type PhoneBookDB YES PhoneBookDB.mdf will be created for us
Add Data Field names and Types 1 Right Click and Choose - Add New Table - 2 Add Data Field names and Types 3 Hit Save Button And Name it PhoneBookTable Hit OK
And Enter some information 2 Add some data 1 Right Click Choose Show Table Data And Enter some information
Hit arrow at upper right corner choose data source Drag and Drop GridView to Default.aspx Hit arrow at upper right corner choose data source <New data source…>
Pick Defaults and Hit OK Choose Database Pick Defaults and Hit OK
Configure Data Source Select
Save the Connection String Hit Next
Test Query
Lets Run it
Lets look at little bit code Default.aspx
Web.config PhoneBookDBConnectionString
End of Part 1 We have seen Part 2 shows how to How to Create SQL Database Binding Database to GridView Part 2 shows how to Add Remove Edit