如何使用 ADO 连接字符串以 SYS 身份连接到 Oracle 数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/179365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I connect to an Oracle database as SYS using an ADO connection string?
提问by JosephStyons
I am trying this:
我正在尝试这个:
Provider=MSDASQL.1;Persist Security Info=False;User ID=sys;Password=pwd;Initial Catalog=DATABASE;Data Source=OdbcDataSource;DBA Privilege=SYSDBA
But I get the error:
但我收到错误:
[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
I'm using Delphi, but answers in any language are welcome.
我正在使用 Delphi,但欢迎任何语言的答案。
Clarification: I am able to connect as a normal user. I run into trouble when I try to connect AS SYSDBA.
说明:我可以作为普通用户进行连接。当我尝试连接 AS SYSDBA 时遇到了麻烦。
回答by Salamander2007
You can't connect as SYSDBA using standard System.Data.OracleClient, as stated by this post : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2245591&SiteID=1.
您不能使用标准 System.Data.OracleClient 作为 SYSDBA 进行连接,如这篇文章所述:http: //forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2245591&SiteID=1。
You can do that using ODP .NET (Oracle Data Provider for .NET), or other third parties library. If you're planning to build serious Oracle Application on .NET, I suggest you at least look at ODP.NET
您可以使用 ODP .NET(用于 .NET 的 Oracle 数据提供程序)或其他第三方库来做到这一点。如果您打算在 .NET 上构建严肃的 Oracle 应用程序,我建议您至少看看 ODP.NET
回答by Matt R
I'm not sure what you mean by connecting as a SYS, but there here is a link to sweet repository of connection strings. I hope you can find your answer there.
我不确定以 SYS 身份连接是什么意思,但这里有一个链接到连接字符串的甜蜜存储库。我希望你能在那里找到你的答案。
回答by David Basarab
Oracle Connection string sample
Oracle 连接字符串示例
You must have your Oracle SID defined in your TNSNames file. Which is the data source.
您必须在 TNSNames 文件中定义您的 Oracle SID。哪个是数据源。
Data Source=oracl;User Id=userID;Password=password;Integrated Security=no
If you are using Visual Studios you can add a data source in the Sever Explore and it will give you the connection string.
如果您使用的是 Visual Studios,您可以在 Sever Explore 中添加一个数据源,它会为您提供连接字符串。
回答by ListenToBob
Posting the answer here as this is the top result when looking for an answer for DBA PRIVILEGE connection string
在此处发布答案,因为这是寻找 DBA PRIVILEGE 连接字符串的答案时的最佳结果
Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCL))); User ID=sys; Password=syspassword; DBA PRIVILEGE=SYSDBA