我已经安装了带有64位和oracle 10g数据库和visual studio 2015的Windows 2008操作系统。
无法连接oracle数据库10g。
现有的开发应用程序是使用Visual Studio 2010开发的,它正在使用oracle 10g数据库在windows xp上工作。
请帮帮我。
答案 0 :(得分:0)
Can you try the below
1. Include Oracle.ManagedDataAccess.dll in your solution.
2. In web.config, Under Configuration and connectionstrings, include the below
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="UATDB" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLEDBIP)(PORT = PORT))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORACLE)))"/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
<connectionStrings>
<add name="UATCONNECTIONSTRING" connectionString="Data Source=UATDB;User Id=username;Password=password;Min Pool Size=10; Connection Lifetime=300;Connection Timeout=300;Incr Pool Size=5;Decr Pool Size=2;" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>
3. Refer the dll in your application
using Oracle.ManagedDataAccess;
using (OracleConnection oraConn = new OracleConnection(strOracleConn))
{
oraConn.Open();
OracleCommand oraCommand = new OracleCommand();
oraCommand.CommandType = System.Data.CommandType.StoredProcedure;
oraCommand.CommandText = "sp name";
oraCommand.Connection = oraConn;
}
Web.config file
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
</configSections>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="UATDB" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = IP)(PORT = PORT))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORACLE)))"/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<customErrors mode="Off"/>
<httpRuntime executionTimeout="600"/>
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization>
<pages controlRenderingCompatibilityVersion="4.0">
<namespaces>
<add namespace="System.Web.Optimization"/>
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
</controls>
</pages>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<connectionStrings>
<add name="UATCONNECTIONSTRING" connectionString="Data Source=UATDB;User Id=user1;Password=pass12;Min Pool Size=10; Connection Lifetime=300;Connection Timeout=300;Incr Pool Size=5;Decr Pool Size=2;" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>
<appSettings>
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
</modules>
</system.webServer>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="../Logs/RunningLog/WrapperRunningLog-" />
</file>
<rollingStyle value="Date" />
<datePattern value="yyyyMMddHH.lo\g" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level - %message%newline" />
</layout>
</appender>
<appender name="RollingLogFileAppenderUpdateStatus" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="../Logs/UpdateStatusLog/StatusLog-" />
</file>
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd.log" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
</root>
<logger name="RunningLog">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="UpdateStatusLog">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppenderUpdateStatus" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
</log4net>
</configuration>
答案 1 :(得分:0)
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</configSections>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="UATDB" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ipadd)(PORT = port))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcle)))"/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
<connectionStrings>
<add name="Audit" connectionString="Provider=MSDAORA;Data Source=UATDB;User Id=userid;Password=password;Min Pool Size=10; Connection Lifetime=300;Connection Timeout=300;Incr Pool Size=5;Decr Pool Size=2;" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no"/>
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>