Addendum: Adding a DB2 Data Source to the Visual Studio 2005 Server Explorer
If youre familiar with the Visual Studio.NET 2003 support that DB2 UDB provides, youll recall that .NET developers writing applications on the DB2 platform were required to work within the IBM Explorer. The IBM Explorer was functionally equivalent to the Server Explorer; however, there were no open interfaces into the Server Explorer in Visual Studio.NET 2003 by which DB2 UDB could leverage to provide some of the features unique to the DB2 UDB plug-in.
The architecture of Visual Studio 2005 changed such that there are now interfaces that let you develop applications that connect to DB2 UDB V8 and DB2 9 databases using the Server Explorer. This provides a more native experience for .NET application developers used to developing applications on SQL Server databases.
To add a DB2 database connection to your Server Explorer, perform the following steps:
Note: If you already have a database connection to the that database you want to provide your ASP.NET Web site with data, you can skip this section.
1. Right-click the Database Connections folder in the Server Explorer and select the Add Connection option. The Add Connection dialog box opens:
2. Ensure that the Data source field points to the (.NET Framework Data Provider for IBM DB2) data provider so that the Server Explorer will use the ADO.NET data provider written by IBM specifically for DB2 UDB and DB2 9 databases.
The DB2 ADO.NET provider is not the default provider shown in this field. To change the database provider to use the one for DB2, click Change and select the IBM DB2 option from the Data source list as shown below (you should also ensure that the IBM DB2 Data Provider for .NET Framework is selected in the Data provider field, but this should be the default):
Note: If you plan to frequently work with DB2 database connections, I recommend you select the Always use this selection check box. When you add another database connection, Visual Studio 2005 will automatically select the DB2 data provider if this option is selected.
3. Enter the server name and port number (separated by a : ) in the Enter server name field. If you are connecting to a local database, you can use the localhost alias for your workstation.
Depending on the version of DB2 that you are running your beta on, you can optionally click Refresh to automatically enumerate all the databases configured to respond to DB2 network database identification requests and automate this process.
4. Enter your user account credentials in the User ID and Password fields. I recommend you save these credentials in the connection string (they are encrypted) by selecting Save my password. Selecting this option makes application development more streamlined, as you are not challenged to provide authentication details during subsequent access requests to the DB2 database.
5. Select the database name from the Select or enter a database name drop-down list, or enter the name manually.
Note: In this article, I chose to connect to the SAMPLE database that is shipped with DB2 UDB V8. If you dont have the SAMPLE database created on your workstation, you can create it now by entering the db2sampl command from a Windows-based command prompt.
6. Optionally use the Specify Connection Options and Specify Filtering Options sections to further customize your database connection. The options associated with these toggles are shown below:
The DB2 support for Visual Studio 2005 comes with a rich set of connection time and filtering options. For the purposes of this article, you can just select the defaults.
7. Test the connection using the Test Connection button.
8. Click OK.
After adding your database connection, the Visual Studio 2005 Server Explorer should look similar to the following:
In the previous figure, you can see that Ive expanded the SAMPLE database connection. Below this database connection is a connection object to a SQL Server 2005 database. Notice the beside this database connection object: all databases appear this way until you click them to make the database connection.
» See All Articles by Columnist Paul C. Zikopoulos
About the Author
Paul C. Zikopoulos, BA, MBA, is an award-winning writer and speaker with the IBM Database Competitive Technology team. He has more than ten years of experience with DB2 and has written over sixty magazine articles and several books about it. Paul has co-authored the books: Information on Demand: Introduction to DB2 9 New Features, IBM DB2 9: New Features, DB2 Version 8: The Official Guide, DB2: The Complete Reference, DB2 Fundamentals Certification for Dummies, DB2 for Dummies, and A DBA's Guide to Databases on Linux. Paul is a DB2 Certified Advanced Technical Expert (DRDA and Cluster/EEE) and a DB2 Certified Solutions Expert (Business Intelligence and Database Administration). In his spare time, he enjoys all sorts of sporting activities, running with his dog Chachi, and trying to figure out the world according to Chloë his new daughter. You can reach him at: firstname.lastname@example.org.
IBM, DB2, DB2 Universal Database, and pureXML are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, and service names may be trademarks or service marks of others.
Copyright International Business Machines Corporation, 2006. All rights reserved.
The opinions, solutions, and advice in this article are from the authors experiences and are not intended to represent official communication from IBM or an endorsement of any products listed within. Neither the author nor IBM is liable for any of the contents in this article. The accuracy of the information in this article is based on the authors knowledge at the time of writing.