SQLTeam.com | Weblogs | Forums

ODBC Stored Procedure

private void RunStoredProcedure()
string customer_name = "";
var conn = new OdbcConnection();
conn.ConnectionString = @"DSN=ABCD;" +
"Uid=TAB;" +
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;

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

        OdbcDataReader reader = command.ExecuteReader();
        while (reader.Read())
            customer_name = reader[0].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;" +

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