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

Related Posts:

  • sample code for call webservice using ajax in asp.net Here we call webservice using ajax update panal and javascript . We see also how an ASP.NET AJAX-enabled web service generates the JavaScript needed … Read More
  • SQL RIGHT JOIN SQL RIGHT JOIN Keyword The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left tab… Read More
  • Anonymous Methods in asp.net In versions of C# previous to 2.0, the only way to declare a delegate was to use named methods. C# 2.0 introduces anonymous methods c#. Creating anon… Read More
  • SQL FULL JOIN SQL FULL JOIN Keyword The FULL JOIN keyword return rows when there is a match in one of the tables. SQL FULL JOIN Syntax SELECT column_name(s) FR… Read More
  • SQL INNER JOIN Keyword SQL INNER JOIN Keyword The INNER JOIN keyword returns rows when there is at least one match in both tables. SQL INNER JOIN Syntax SELECT column_n… Read More

0 comments:

Post a Comment