Running a stored procedure with 2 parameters

  • Thread starter Thread starter Danroved
  • Start date Start date
D

Danroved

Guest
private void RunStoredProcedure()
{
string customer_name = "";
var conn = new OdbcConnection();
conn.ConnectionString = @"DSN=ABCD;" +
"Uid=ABCD;" +
"Pwd=ABCDEFG;";
OdbcCommand command = new OdbcCommand("{ ? = CALL GETUSERNAME(?) }", conn);
command.CommandType = CommandType.StoredProcedure;

OdbcParameter parameter = new OdbcParameter();
parameter.ParameterName = "p_userid";
parameter.OdbcType = OdbcType.VarChar;
parameter.Size = 7;
parameter.Direction = ParameterDirection.Input;
parameter.Value = "drabino";
command.Parameters.Add(parameter);

OdbcParameter parameter2 = new OdbcParameter();
parameter2.ParameterName = "v_username";
parameter2.OdbcType = OdbcType.VarChar;
parameter2.Size = 50;
parameter2.Direction = ParameterDirection.Output;
command.Parameters.Add(parameter2);

conn.Open();
OdbcDataReader reader = command.ExecuteReader();
while (reader.Read())
{
customer_name = reader[0].ToString();
}
conn.Close();
MessageBox.Show(customer_name.ToString());
}

I keep getting ERROR [HY000] [Oracle][ODBC][Ora]ORA-24334: no descriptor for this position.

What am I doing wrong?

Continue reading...
 
Back
Top