Oracle 如何解决';SqlCommand';是否存在于.net核心中?
我尝试使用Oracle写入DLL,然后将其写入.NET核心程序,但出现以下错误消息:Oracle 如何解决';SqlCommand';是否存在于.net核心中?,oracle,.net-core,system.data,Oracle,.net Core,System.data,我尝试使用Oracle写入DLL,然后将其写入.NET核心程序,但出现以下错误消息: This type 'SqlCommand' exists between 'System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193
This type 'SqlCommand' exists between 'System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
如何解决此错误消息
下面是我的代码
using Microsoft.Extensions.Configuration;
using msClinicTxSvc.ViewModels;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
namespace msClinicTxSvc.Models
{
public class ImportService : IDisposable
{
public bool contest(ImportViewModel ctd)
{
if (ctd.Source_Type == "MSSQL")
{
try
{
System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection(@"Data Source =" + ctd.HIS_Server + "; Initial Catalog =" + ctd.HIS_DB + "; User ID = " + ctd.HIS_User + "; PassWord =" + ctd.HIS_PW + ";");
sqlcon.Open();
sqlcon.Close();
return true;
}
catch (Exception)
{
return false;
}
}
else if (ctd.Source_Type == "MySQL")
{
try
{
MySqlConnection mysql = new MySqlConnection("Data Source=" + ctd.HIS_Server + ";Database=" + ctd.HIS_DB + ";User Id=" + ctd.HIS_User + ";Password=" + ctd.HIS_PW + ";");
mysql.Open();
mysql.Close();
return true;
}
catch (Exception)
{
return false;
}
}
else
{
try
{
OracleConnection con = new OracleConnection("Data Source=" + server + "/" + db + ";User Id=" + userid + ";Password=" + pw + ";");
con.Open();
con.Close();
return true;
}
catch (Exception)
{
return false;
}
}
}
}
}
我希望它可以连接到MSSQL、MySQL和Oracle。请向我们展示您的代码
System.Data.SqlClient
听起来像SQL Server,但不像Oracle客户端。您不导入任何Oracle命名空间。如何使用OracleConnection
?@Wernfried Domscheit我尝试添加Oracle名称空间,但似乎“对类型'Component'的引用表明它在'System'中定义,但未找到。”。因此,我通过NuGet将Oracle的代码作为DLL写入我的程序;请出示您的密码System.Data.SqlClient
听起来像SQL Server,但不像Oracle客户端。您不导入任何Oracle命名空间。如何使用OracleConnection
?@Wernfried Domscheit我尝试添加Oracle名称空间,但似乎“对类型'Component'的引用表明它在'System'中定义,但未找到。”。因此,我通过NuGet将Oracle的代码作为DLL写入我的程序;