Welcome Guest!
Create Account | Login
Locator+ Code:

FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly
get the code
more resources

Manage Data With VS 2005
Visual Studio 2005's new visual data tools and data-bound controls, together with ADO.NET 2.0 data sources, simplify creating scalable, data-intensive Smart Client and Web applications.
by Roger Jennings

November 7, 2005

Technology Toolbox: Visual Basic; XML; Visual Studio 2005, Visual Basic Express, Visual C# Express, or Visual Web Developer; SQL Server 2005 Developer Edition or higher, or SQL Server 2005 Express Edition

The Microsoft Developer Tools Roadmap promised that Visual Studio 2005 would "radically enhance the experience of manipulating and retrieving data" by simplifying "data source design from within the development environment" (see Additional Resources). Planned UI enhancements included the ability to create data sources from local and remote data, business objects, and Web services for generating "data-bound forms without code." Microsoft also encouraged writing VB 8.0 or C# 2.0 managed code to replace or supplement T-SQL stored procedures and user-defined functions, as well as to generate user-defined data types (see the sidebar, "When to Use the SQLCLR"). Now that Microsoft has finally released VS 2005, SQL Server 2005, and their Express editions, it's time to put the developer tools teams' feet to the fire with a real-world evaluation of their handiwork.


Microsoft invested thousands of developer hours to optimize VS 2005's techniques for constructing Smart Client and Web-based data display and editing forms. It has made significant progress in this area, but we're still waiting for the day when deploying totally codeless, data-intensive applications in production environments will be practical. That said, I believe VS 2005 is likely to cut overall development costs for most two-tier or three-tier database front ends by 50 percent or more compared with VS 6.0, 2002, or 2003. Download and run this article's almost-codeless sample projects, and see if you agree.

Microsoft includes significant new improvements for handling data in both Smart Client and Web projects. I'll show you how to use the new ADO.NET 2.0 features and data-bound controls with emphasis on rapid application development (RAD) techniques for Smart Client projects and ASP.NET 2.0 Web sites. The sample code includes a Visual Basic SmartClient1.sln project and DataWebSite1 file-system Web site as working models that demonstrate these new VS 2005 features.

It's ironic that the Visual Basic team owned the data design-time experience for Smart Client (née Windows Forms) applications during most of the Whidbey beta period. After all, the stated objective for the development environment is eliminating or—more accurately—minimizing the code needed to implement data-bound forms. On the other hand, VB is the most popular RAD language for custom business projects, so the VB team's ownership of the Data Sources window, DataSet designer/editor, most of Server Explorer, and local data features makes sense. The VS Data team is in charge of data at run time, as well as SQL Server projects, database projects, and Visual FoxPro. The ASP.NET 2.0 (née Venus) team owns the data design-time experience for Web Forms, which differs considerably from the Smart Client approach.

The first data-related change from VS 2003 that you'll notice when opening a new Windows project or Web site in VS 2005 is the upgraded Server Explorer window. The new Add Connection dialog defaults to the SqlClient native data provider for SQL Server instead of the VS 2003 Data Link Properties dialog's hard-wired OLE DB provider. The Add Connection dialog also simplifies auto-attaching a SQL Server MDF/LDF file pair, which is the preferred approach for connections to local SQL Server instances. Attached SQL Server 2005 Express databases automatically detach after all connections close, which enables XCOPY deployment for Smart Client apps or Web sites with local data requirements. You can use SQLCMD or OSQL to manually detach an MSDE 2000 database file, copy it, and then use a connection string for the new connection to attach the copy to a local SQL Server 2005 Express instance. The Add Connection dialog's Data Source Change button lets you select relational database management system (RDBMS) alternatives, such as the native data provider for Oracle 7.3, 8i, and 9i; SQL Server Mobile Edition; Access (Jet) databases; ODBC; or other OLE DB drivers. The Server Explorer and its Add Connection dialog are identical for Smart Client projects and Web sites.

The next step for data-dependent Smart Client projects—after you've added a connection to a database server or file—is to add a new data source to the Data Sources window. The Data Sources window, not Server Explorer, is the starting point for the drag-and-drop addition of data components and data-bound controls to Windows Forms. (Unlike VS 2003, you can't drag tables from VS 2005's Server Explorer to add SqlConnection and SqlDataAdapter objects to the form designer's tray.) Choosing Add New Data Source from the Data menu starts the Data Source Configuration Wizard, which offers Database, Web Service, and Object options. Database data sources let you save a connection string clone to the App.config file and generate a typed DataSet from the database's tables, views, stored procedures, or functions. For simplicity and familiarity, this article uses Northwind rather than AdventureWorks tables for all examples.

Back to top

Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home