“ORA-01031:权限不足”在connection.Open();

时间:2013-11-09 23:49:36

标签: c# oracle10g ado dbproviderfactories

我正在尝试使用Oracle.ManagedDataAccess.Client作为SYSDBA从C#Desktop应用程序连接到Windows 7 64x版本上的ORACLE 10g数据库。

这是我在配置文件中的连接字符串:

<add name="default" connectionString="User Id=scott;Password=tiger;DBA Privilege=SYSDBA;Data Source=(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = sherif-PC)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =orcl2)));" providerName="Oracle.ManagedDataAccess.Client"/>

这是代码:

 ConnectionStringSettings ConnectString = ConfigurationManager.ConnectionStrings["default"];
            _dbFact = DbProviderFactories.GetFactory(ConnectString.ProviderName);
            _con = _dbFact.CreateConnection();
            _con.ConnectionString = ConnectString.ConnectionString;
            using (_con)
            {
                _con.Open();
                using (_cmd = _con.CreateCommand())
                {
                    _cmd.CommandText = "select * from EMP;";
                    using (IDataReader reader = _cmd.ExecuteReader())
                    {
                        res = reader.GetString(1);
                    }
                }
                _con.Close();

                MessageBox.Show(res);
            }

我必须使用DbProviderFactory,因为它必须是针对不同种类的dbs的通用解决方案

0 个答案:

没有答案