Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data
ASP.NET, Programming, Windows March 26th, 2010Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data
On this post, you will see how to develop an ASP.NET web application that query data from SQL Server 2005 and display the result on a GridView object using SqlDataSource web control so you don’t have to write any code!
Step-by-step-
- Drag a SqlDataSource object from Toolbox to a Web Form.

- On SqlDataSource1 object, click Configure Data Source.

- On Choose Your Data Connection, click New Connection.

- On Add Connection, select Data Source as Microsoft SQL Server (SqlClient). Then, type the Server name of the SQL Server and select a database. On this example, the server is BKKSQL001\INSTANCE01 and Northwind is the database.

- On Save the Connection String to the Application Configuration File, click Next to continue.

- On Configure the Select Statement, select Specify columns from table or view and select Products table. Then, check ProductID, ProductName and UnitPrice columns. Click Next.

- On Test Query, you can click on Test Query button to verify the query result. Then, click Finish.

- Drag a GridView object from Toolbox to the Web Form. Then, choose the Data Source to the one that you have just created.

- Build and run the project. You will see the result as the figure below.

Related post
- Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data From part 1: SELECT Data,...
- Accessing SQL Server on ASP.NET Web Application using ADO.NET ADO.NET is a set of components that can be used to access data and data services. The objects of ADO.NET...
- Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET Introduction Before I started, let’s get to know what RSS is. Quoted from Wikipedia.org RSS is a family of Web...
- Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part II: C# This post, I’ll cover only in the second section “Create ASP.NET Web Application on MS Visual Studio 2005 (C#)”. I’m...
Related posts:



