string userName = ""; using (OracleConnection oraConn = new OracleConnection(connString))
{
if (oraConn.State != ConnectionState.Open)
{
oraConn.Open();
} OracleCommand oraCommand = new OracleCommand("GetUserInfo",oraConn);
oraCommand.CommandType = CommandType.StoredProcedure;
oraCommand.Parameters.Add("v_userid", OracleType.VarChar);
oraCommand.Parameters["v_userid"].Value = userId;
oraCommand.Parameters.Add("v_username", OracleType.VarChar);
oraCommand.Parameters["v_username"].Value = ParameterDirection.Output;
oraCommand.ExecuteNonQuery();
userName = oraCommand.Parameters["v_username"].Value.ToString(); if (oraConn.State == ConnectionState.Open)
{
oraConn.Close();
}
} return userName;以上这段代码是我调用存储过程,根据userid查询username。但总是取不到返回值,大家帮忙看下什么原因。
存储过程:CREATE OR REPLACE PROCEDURE GetUserInfo
(
v_userId in varchar,
v_userName out varchar
)
is
BEGIN
SELECT u.username into v_userName FROM users u WHERE u.userid = v_userid;
END;
解决方案 »
- 在dataview中筛选时间段中的内容,请高手进来看下问题,帮解答下,谢谢!
- 公司老总们,经理们问你们一个问题
- 请问1.逻辑和数据是不是一定要和窗体绑定? 2.窗体之间的数据传递
- 本人应老婆要求做的日历(C# winform+Access),免费给大家代码
- 属性属性get、set不明白不明白
- 怎么做一个安装让dotnetfx.exe和langpack.exe两个安装合并在一块成为dotnet.exe,用户直接安装dotnet.exe就可以了
- 高分送!!!我想在Panel上用鼠标画直线!
- c#写的图像程序保存的图像文件,文件内容中有一部分是png格式,怎样让自己定义的文件大图标显示png那部分的图片?
- 方法调用AVICAP32.dll 失败 错误提示是安全透明方法无法调用本机代码,需要安全关键或者安全可靠关键才可以。这怎么解决啊。
- c#中如何判断中文字符串的真实长度
- 初学者向大家请教学习C#的经验。谢谢!
- 我该怎么办???
这个参数要设置大小
oraCommand.Parameters["v_username"].Value = ParameterDirection.Output;改成oraCommand.Parameters["v_username"].Direction= ParameterDirection.Output;