ServerName 主机名(xx.xx.xx.xx),
UserName 用户名,
Password 密码,
DataBaseName SID,
port 端口号
直接调用该方法即可,如果出现
Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040) 问题,参考下面连接
https://blog.csdn.net/qq_27524147/article/details/127067624
public static string GetProc(string procname, string ServerName, string UserName, string Password, string DataBaseName, string port)
{
//ServerName, UserName, Password, DataBaseName, port
string connString = $"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={ServerName})(PORT={port}))(CONNECT_DATA=(SERVICE_NAME={DataBaseName})));Persist Security Info=True;User ID= {UserName};Password={Password};";
OracleConnection conn = new OracleConnection(connString);//实例化
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
//过程名
cmd.CommandText = procname;
//有入参就设置入参,我这过程只有出参,就不演示入参的了
cmd.Parameters.Add("V_RETURNMSG", OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output;
cmd.Parameters.Add("V_RETURNVALUE", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
cmd.ExecuteReader();
//接受执行存储过程之后返回的参数值
string sa = cmd.Parameters["V_RETURNMSG"].Value.ToString();
return sa;
}
过程内容执行成功(成功返回 ‘ ’,由个人自行决定成功返回结果内容)情况:
过程内容执行失败情况: