microsoft提供的oledb是支持db2的,不过可能会有小bug,不过要驱动odbc可以去微软下载odbc支持的驱动.
解决方案 »
- 用ocx遇到的问题
- 在tabControl1里显示图片
- 求时间差
- 一个简单的问题,就是我把我难住了,求好心人帮忙
- VC中调用vs2005写的C#COM组件注册
- datagrid中datetime类型取值问题!~
- 我要写毕业论文,请各位高手看看这几个基类的具体作用是什么?我不是太明白!谢谢了!
- C# 中有没有像Java中 Class.forName().newInstance() 这样动态创建类的实例的东东??
- C# 调用 C 写的DLL
- 我用一个DATASET 连接一个DATAGRID 我修改了DATAGRID 也就修改了 DATASET 需要加个什么属性
- 没分了,问个简单的问题
- 怎样用C#获取Form上或控件上某一点的颜色,并且重新设置颜色?急!!在线等!!
里面有“客户机配置辅助程序”,设置一个ODBC数据源,就OK
Using an OleDb .NET Managed Provider Both Microsoft and IBM recommend utilizing an OleDb data provider for accessing most DB2 data when either DB2 V7 or lower is used or when a COM object is the caller. Within the .NET framework, OleDb providers are exposed via COM InterOp and essentially use the same drivers available for ADO development.
Using an ODBC .NET Managed Provider This provides access to native ODBC drivers the same way the OLEDb .NET Data Provider provides access to native OLEDb providers. The ODBC .NET Data Provider is an add-on component to the .NET Framework. The ODBC .NET Data Provider is intended to work with all compliant ODBC drivers.
Using the IBM DB2 .NET Provider (Beta) This provides ADO.NET connectivity to DB2 V8.1. The DB2 .NET Data Provider is an add-in component to the Visual Studio .NET Framework. This provider accesses IBM DB2 database servers running on variety of hardware and operating system platforms. At the time of this writing, the provider is still beta but is expected to be in production soon. The DB2 .Net Data Provider provides connectivity from applications written using ADO.NET to the following DB2 family of servers:
DB2 Universal Database Version 8.1 running on Windows, UNIX and Linux
DB2 Universal Database for z/OS and OS/390 V6.1 and later using DB2 Connect V8.1
The different connection strings highlight the syntactical difference between scenarios. The OleDb connection string ...
Provider=IBMDADB2.1;User ID=db2admin;Password=db2admin;Data Source=SAMPLE
The ODBC connection string ...
DSN=DB2V8;UID=db2admin;PWD=db2admin
The IBM Managed Provider connection string ...
Database=SAMPLE;User ID=db2admin;Password=db2admin;Server=IREK
Comparing Code Level AccessWhen you work with DB2 data access code, most operations are largely the same as you would expect as compared to working with other databases. Here I compare some code across connection techniques. In each of the following code snippets, we are trying to show some of the mechanics of accessing the database and managing data. Notice how the steps are the same for each technique. You start by creating the connection object, then creating a command object. In this simple example, I'm just retrieving a scalar value of the count of rows in this particular table. Finally, we execute the command's ExecuteScalar() method to return the integer. With Ole Db...
private OleDbConnection cn = new OleDbConnection(connectionString); OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM STAFF", cn); int rc = Convert.ToInt32(cmd.ExecuteScalar());
With ODBC...
private OdbcConnection cn = new OdbcConnection(connectionString);
OdbcCommand cmd = new OdbcCommand("SELECT COUNT(*) FROM STAFF", cn);
int rc = Convert.ToInt32(cmd.ExecuteScalar());
With IBM's Managed Provider...
private DB2Connection cn = new DB2Connection(connectionString);
DB2Command cmd = new DB2Command("SELECT COUNT(*) FROM STAFF", cn);
int rc = Convert.ToInt32(cmd.ExecuteScalar());
What's key here is that nothing reable or confusing is happening!
http://www.15seconds.com/issue/030623.htm
OLEDB, OleDbConnection (.NET) from ms
TCP/IP:
"Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
o;APPC:
"Provider=DB2OLEDB;APPC Local LU Alias=MyAlias;APPC Remote LU Alias=MyRemote;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
http://www-900.ibm.com/developerWorks/cn/dmdd/index.shtml
不过用起来感觉不大顺手