The 'NZOLEDB' provider is not registered on the local machine

时间:2017-06-19 14:00:02

标签: c# asp.net odbc oledb netezza

I am trying to connect with NETEZZA database and below is my connection string in web.config

 <add name="MyConnection" connectionString="Provider=NZOLEDB;Data Source=XXX.XXX.XXX.XXX;port=XXXX;Initial Catalog=myDatabase;Persist Security Info=FALSE;USER ID=myUserID;password=myPassword" providerName="System.Data.OleDb" />

But I am getting the error The 'NZOLEDB' provider is not registered on the local machine.

Below is rest code

public DatabaseType GetDbType()
        {
            DatabaseType dbtype = DatabaseType.Unknown;
            if (databaseTypes == "MySqlConnection")
                dbtype = DatabaseType.MySql;
            else if (databaseTypes == "SQLServerConnection")
                dbtype = DatabaseType.MSSql;
            else if (databaseTypes == "OleDbConnection")
                dbtype = DatabaseType.Oledb;
            else if (databaseTypes == "OracleConnection")
                dbtype = DatabaseType.Oledb;
            return dbtype;
        }

Here i am assuming Oledb provider.

 public IDbConnection CreateConnection(string connectionString, DatabaseType database)
        {
            IDbConnection connection;
            switch (database)
            {
                case DatabaseType.MSSql:
                    connection = new SqlConnection();
                    break;
                case DatabaseType.MySql:
                    connection = new MySqlConnection();
                    break;
                case DatabaseType.Oledb:
                    connection = new OleDbConnection();
                    break;
                case DatabaseType.ODBC:
                    connection = new OdbcConnection();
                    break;
                default:
                    connection = new SqlConnection();
                    break;
            }
            connection.ConnectionString = connectionString;
            return connection;
        }

0 个答案:

没有答案