How to connect to DB2?(如何连接到 DB2?)
问题描述
我必须连接到安装在其他系统上的 DB2 数据库.我有服务器的机器名称、我想连接的数据库名称、端口号和凭据.我的系统上没有为 DB2 安装任何客户端.我想使用 OLEDB 连接.
I have to connect to a DB2 database installed on some other system. I have the machine name of the server, the database name to which I would like to connect to, the port number and the credentials. I do not have any client installed on my system for DB2. I want to use OLEDB connections.
我可以在不安装客户端的情况下实现这一点吗?还让我知道哪些参考 dll 将帮助我实现这一目标,即我应该使用什么 - IBM OLE DB Provider for DB2 或 Microsoft OLEDB provider for IBM DB2 或其他?我在哪里可以找到它们?
Can I achieve this without installing a client? Also let me know what reference dlls would help me in achieving this i.e. what should I use - IBM OLE DB Provider for DB2 or Microsoft OLEDB provider for IBM DB2 or some other? Where do I find them?
推荐答案
OLEDB 参考 .NET DB2 OLEDB 先决条件
另请参考:有什么区别OLE DB 和 ODBC 数据源之间的关系?
对于ODBC连接,我使用如下
连接字符串
<add name="DB2ConnectionString_XA"
connectionString="Driver={IBM DB2 ODBC DRIVER};Database=MyDB;Hostname=DB2GWXX;Protocol=TCPIP;Port=3700;Uid=ffghxa;Pwd=xxxx;"/>
代码:
using (OdbcConnection odbcConnection = new OdbcConnection(db2ConnectionString))
{
odbcConnection.Open();
// string commandText = "";
using (OdbcCommand command = new OdbcCommand(commandText, odbcConnection))
{
command.CommandType = System.Data.CommandType.Text;
using (OdbcDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
}
}
}
}
}
这篇关于如何连接到 DB2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何连接到 DB2?
基础教程推荐
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
