我已经在另一台PC(A)上安装了Oracle DB,并试图从我的电脑(B)建立连接。现在,当我尝试调试应用程序时,我收到此错误 - “[DBNETLIB] [ConnectionOpen(ParseConnectParams())。]无效连接。”
public void InsertionTest()
{
string cmdText = @"Insert into O_TEST_TABLE (ID,Name,MOBILE) Values (4, 'rD','798984');";
string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["HR"].ConnectionString;
using (OleDbConnection con = new OleDbConnection(ConnectionString))// "Provider=SQLOLEDB; DATA SOURCE=172.16.1.220:1521/orcl;PASSWORD=hr;PERSIST SECURITY INFO=True;USER ID=hr"))
using (OleDbCommand cmd = new OleDbCommand(cmdText, con))
{
con.Open();
int rowsUpdated = cmd.ExecuteNonQuery();
if (rowsUpdated == 0)
{
Console.WriteLine("Failed!!!");
}
else
{
Console.WriteLine("Success.");
}
}
}
在我的网络配置文件中,连接字符串是 -
<connectionStrings>
<add name="HR" connectionString="Provider=SQLOLEDB;Initial Catalog=HR;DATA SOURCE=172.16.1.13:1521/orcl;PASSWORD=hr;PERSIST SECURITY INFO=True;USER ID=hr; OLEDB.NET=True " />
</connectionStrings>
答案 0 :(得分:1)
我觉得提供者应该是Provider=OraOLEDB.Oracle