Working with Databases in ASP.NET 2.0 and Visual Studio 2005 09 Nov 2005 00:00 GMT
On November 7th, 2005, Microsoft officially released
.NET 2.0 (including ASP.NET 2.0), Visual Studio 2005,
and SQL Server 2005. All of these components were designed to work side-by-side
with previous versions. That is, both ASP.NET version 1.x and version 2.0 can be installed on the same machine; you can have
both Visual Studio .NET 2002/2003 and Visual Studio 2005, as well as both SQL Server 2000 and SQL Server 2005. Furthermore,
Microsoft is releasing an "Express" SKU of Visual Studio 2005 and SQL Server 2005.
The Express line does not have all the features of the professional editions, but you can't beat the price - free for SQL
Server 2005 and a free for one year for the Express line of Visual Studio 2005! (More information on the Express SKU pricing
is available here.)
Since the vast majority of interesting ASP.NET web applications access data in some manner, one of the first questions many
developers have when exploring 2.0 is, "How do I work with databases in 2.0?" and, "What databases can I connect to through
an ASP.NET 2.0 page?" The good news is that 2.0 is everything that version 1.x was plus additional features. Therefore,
whatever databases you could work with in 1.x and whatever code you used will work in 2.0.
In addition to 2.0 supporting the 1.x style of data access, 2.0 also includes a number of new datasource controls, which make
accessing and modifying database data a breeze. With datasource controls, you simply add the control to the ASP.NET page
and configure the connection string and SQL query through the control's properties. This datasource control can then be
bound to a data Web control (such as the GridView)
by setting the data Web control's DataSourceID property to the ID of the datasource control.
The days of having to write code to create the connection, create the command, specify the SQL query, retrieve a DataReader
or DataSet, and bind it to the data Web control are now over. These steps can be replaced through using the declarative
datasource controls. (Of course, you can still access data programmatically using the familiar steps/classes from your 1.x code.)
In this article we'll look at how to connect and display data from a database in ASP.NET 2.0. Specifically, we'll see how
to use both the programmatic and declarative approaches for accessing data, as well as the basics of displaying data using
the GridView control. Read on to learn more!
Read More >
Source: 4GuysFromRolla