问题描述
我试图使默认的ASP.NET MVC应用程序中使用远程Oracle数据库。我已经设置了Oracle客户端,可以从服务器资源管理器访问远程数据库。
我试图从
<&是connectionStrings GT;
<添加名称=ApplicationServices
的connectionString =数据源= \\ SQLEX $ P $干燥综合征;集成安全性= SSPI; AttachDBFilename = | DataDirectory目录| ASPNETDB.MDF;用户实例=真
的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;
到
<&是connectionStrings GT;
<添加名称=ApplicationServices
的connectionString =数据源= ORCL;坚持安全信息= TRUE;用户ID =用户名;密码= myPassword;复制代码统一code = TRUE
的providerName =Oracle.DataAccess.Client/>
< /&是connectionStrings GT;
我用从服务器资源管理器>数据连接> orcl.instance
连接字符串在创建新的用户,我得到的AccountModels.cs以下错误
试图初始化System.Data.SqlClient.SqlConnection对象时发生错误。这是为连接字符串提供的值可能是错误的,或者它可能包含一个无效的语法。
参数名:的connectionString
任何想法,我在这里丢失?
编辑:
看起来像 AccountModels.cs
下面的代码片断使用 System.Data.SqlClient.SqlConnection
。我如何使用ODP版本。
公共类AccountMembershipService:IMembershipService
{
私人只读的MembershipProvider _provider;
...
}
您必须使用的 API,而不是的SqlClient
提供商。在 System.Data.SqlClient的
类是仅用于Microsoft SQL Server数据库。
编辑:
甲骨文文章:
I am trying to make the default ASP.NET MVC application use a remote Oracle database. I have set up the oracle client and can access the remote database from Server Explorer.I tried changing the connection string from
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
to
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=orcl;Persist Security Info=True;User ID=username;Password=mypassword;Unicode=True"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
I used the connection string from Server Explorer > Data Connection > orcl.instance
When creating a new user, I am getting the following error in AccountModels.cs
An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax.
Parameter name: connectionString
Any idea what am I missing here?
EDIT:Looks like the following snippet in AccountModels.cs
uses System.Data.SqlClient.SqlConnection
. How can I use the ODP version.
public class AccountMembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
...
}
You have to use ODP.NET API instead of SqlClient
provider. The System.Data.SqlClient
classes are for Microsoft SQL server database only.
EDIT:
Oracle article : Oracle Providers for ASP.NET Installation
这篇关于使用Oracle数据库的默认ASP.NET MVC应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!