C # access to DB2 databases

Source: Internet
Author: User
Tags db2 db2 client db2 driver ibm db2 odbc ole visual studio

Non-SQL Server databases such as IBM DB2, which are accessed in Visual Studio.NET beta version 1, typically use the ODBC method of Ado.net, while in Beta 2 the database is accessed using OLE DB methods instead.

The connection string in BETA1 is primarily required to declare the ODBC DNS name of the database, but the string of OLE DB connections in Beta 2 is more complex and the classes used are not the same. Because the database such as DB2 is used widely in the application of mainframe. NET will naturally support this kind of programming development, and for this, the DB2 development of OLE DB will be elaborated in the following step.

OLE DB for DB2 driver

First, the DB2 OLE DB driver is not directly available in Visual Studio.NET and Windows Server, so download the Microsoft Host Integration Server 2000 software, which contains OLE DB Provider and ODBC driver for DB2, download the server-side package and choose to install the data integration at installation time, and you can use its OLE DB DB2 drive when the installation is complete.

Setting up a database connection

First, we need to configure the DB2 client settings, open the Server Explorer in the View Select item, add a connection to its data connection, select Microsoft OLE DB Provider for DB2 when specifying the program options, and complete the following information in the next connection option:

Data source:qcdb (please change as appropriate)

Network:tcp/ip

IP Address: Database server addresses

Network PORT:DB2 Service Port

Username: User name for database access rights

Password: This user password

Database Initial CATALOG:QCDB

Package collection:qcdb

Default Schema:userid

The next advanced option is to select the corresponding code page and CCSID in the respective national languages, and finally press the confirm key to complete the connection.

Suppose qcdb This DB2 database has a new data table for address, it contains four fields: name, email, age, and address, we can use Server Explorer to open the connection and the data table, and enter a number of Chinese records to determine whether the characters are displayed correctly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.