Sunday, July 22, 2012

Creating a Connection to a SQL Server Database


1 While the code in this book was being tested, we set up a virtual directory called BegASPNETdb, mapped to a file system directory called C:\BegASPNETdb\webroot. To do the same, go to Start | Settings | Control Panel | Administrative Tools | Personal Web Manager, and enter the following in the Add Directory dialog:













2  In the webroot folder, create a text file called web.config, and fill it with exactly the following:


  
     
     
  
The presence of this file will ensure that if and when anything goes wrong with one of our ASPX files, we'll get a useful, descriptive error message.

3 Create a subfolder called C:\BegASPNETdb\webroot\ch03, and place a new text file called SQLServer_connection.aspx inside it.

4 Add the following code

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>


  
    Beginning ASP.NET Databases Chapter 3
  

  
    

First Example: Listing data from the Employees table

runat="server" GridLines="None" BackColor="LightBlue" CellPadding="5" CellSpacing="5" BorderWidth="2" BorderColor="Black" ToolTip="Includes only those employees who are at HQ" />

5 Everything is now in place for you to browse to 
http://localhost/BegASPNETdb/ch03/SQLServer_connection.aspx, where you should 
see the screen overleaf.













 



If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website

0 comments:

Post a Comment