gpt4 book ai didi

c# - 与 Oracle 数据库连接失败

转载 作者:太空宇宙 更新时间:2023-11-03 12:39:19 30 4
gpt4 key购买 nike

代码:

private void Button_Click_6(object sender, RoutedEventArgs e)
{
TimerView tobj = new TimerView();
tobj.Show();
string OracleServer = "Data Source=(DESCRIPTION="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=DLDT-0897.nectechnologies.in)(PORT=1521))"
+ "(CONNECT_DATA=(SERVICE_NAME=XE)));"
+ "User ID=system;Password=abc@1234;";
public bool Open()
{
try
{
conn = new OracleConnection(OracleServer);
conn.Open();
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return false;
}

conn.Open() 错误:

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. WpfApplication

最佳答案

ODP.NET 包有两种版本:一种用于 32 位程序,一种用于 64 位程序。编译时必须选择一个,否则在运行程序时可能会遇到麻烦。因此,您最好从 MSIL 切换到 32 位模式(以支持两种处理器体系结构)。然后您需要包含 32 位版本的 ODP.NET(现在您使用的是 64 位)。

更好的选择可能是使用托管的 ODP.NET 库,它支持两种处理器架构,因为它不再依赖于 OCI。您可以找到最新版本 here .

关于c# - 与 Oracle 数据库连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39609419/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com