SQLTeam.com | Weblogs | Forums

ODBC Stored Procedure

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

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

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

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

What is your question?

I get an error when I execute the code

The error comes up at executenonquery()

I named the two parameters parameter and parameter1. Do I call them the same name?might that be the problem?

Please post the error?

yosiasz is right -- the first step is to post the error exactly as it occurs, with any line number information it puts out.

But with a cursory look, I noticed this:

conn.ConnectionString = @"DSN=ABCD;" +
"Uid=TAB;" +
"Pwd='******';

Are you missing a double quote after the last semicolon?

The connection string works; I might have missed the semi colon when I pasted it into the forum. I will copy the error tomorrow since I have left work. Thank you and hope to hear back from you tomorrow.

We are hoping to hear back from you with the error :wink:

I get an error:

ORA-24334: no descriptor the this position

https://www.oraexcel.com/database-oracle-11gR2-ORA-24334

https://lmgtfy.com/