.net - C# 5.0 Visual Studio 2012 中 iSeries 的 OLEDB 连接字符串

标签 .net sql ibm-midrange

我需要在 C# 5.0 中的 VisualStudio 2012 中使用 OLEDB 建立 ConnectionString 所以下面是编码:

 SQLConn = new SqlConnection("Data Source=STX;Persist Security Info=False;
  UserID=JG0149;Password=MYPASS;Initial Catalog=LIBJG");

这些凭证在 STX iSeries 系统上运行良好

有很多使用 VS 2010 和 C# 4.0 的示例,但它不适用于 C# 5.0,类似于 www.connectionstring,com/as-400/中的示例

SQLConn = new SqlConnection("Provider=IBMDA400;Data Source=STX;User Id=JG0149; Password=MYPASS;
Default Collection=LIBJG")

但是VS2012不接受Provider参数并请求其他的

请问有人可以在 VS2012 中使用 ConnectionString 连接到 iSeries 进行共享吗?

最佳答案

SqlConnection专门用于 SQL Server。

使用OleDbConnection以及其他提供商的相关类(class)。

using (var connection = new OleDbConnection(
        "Provider=IBMDA400;Data Source=STX;User Id=JG0149; Password=MYPASS;Default Collection=LIBJG"))
{
    var command = new OleDbCommand("SELECT NOW() FROM SYSIBM.SYSDUMMY1", connection);
    connection.Open();
    var reader = command.ExecuteReader();
    if (reader.HasRows)
    {
        while (reader.Read())
        {
            Console.WriteLine(reader.GetString(0));
        }
        reader.Close();
    }
    connection.Close();
}

我在 Visual Studio 2012/.NET 4.5 中验证了上述内容。


Microsoft 似乎正在插入回归 ODBC 并逐步淘汰 OLE DB。

SQL Server Blog: Microsoft Aligning with ODBC

The marketplace is moving away from OLE DB and towards ODBC, with an eye towards supporting PHP and multi-platform solutions.

Microsoft SQLNCli team blog: Microsoft is Aligning with ODBC for Native Relational Data Access

We encourage you to adopt ODBC in the development of your new and future versions of your application.

关于.net - C# 5.0 Visual Studio 2012 中 iSeries 的 OLEDB 连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18087252/

相关文章:

c# - PrintSystemJobInfo.JobStream 坏了吗?

c# - itunes 正在听

c# - 如何使用 LibGit2Sharp 从 Git 获取更改?

sql - 按相关性查询和排序

sql - 两列总计不起作用

c# - 按依赖项对 .NET 程序集进行排序

c# - 使用 C# 将 PDF 作为字节数组插入 SQL Server 存储过程

java.sql.SQLException : Bad connection URL while accessing the database

sql - AS400 SQL查询类似于原生AS400中的CLRLIB(清库)

Tomcat JNDI 连接行为不同于 JDBC 连接