Environment versions
Network:
Windows 2003 Server
>Its supposed to use the @ sign to change the value of the variable.
Yes - to define it as an out. But the name of the parameter in the collection is "iRetorno" not "@iRetorno"
>But i already tried with @ and without @ and none works.
Works for me (i.e. no compile error)
>
>>Hi,
>>Shouldn't it be:
>> cmdCommand.Parameters["iRetorno"].Direction = ParameterDirection.Output;
>>Hi all, i have this code in C#: that opens a connection to a .dbc and execute a stored procedure, i need 1 parameter be changed on procedure and return to C# with a new value, the resultset is working ok.
>>
>> private void Button1_Click(object sender, EventArgs e)
>> {
>> // Create the Connection
>> Int32 iRetorno = 1;
>> OleDbConnection cnnConnection = new OleDbConnection(connectionStatement);
>> // Create the command
>> OleDbDataAdapter dx = new OleDbDataAdapter();
>> DataTable dt = new DataTable();
>> OleDbCommand cmdCommand = new OleDbCommand("test", cnnConnection);
>> cmdCommand.CommandTimeout = cnnConnection.ConnectionTimeout;
>> cmdCommand.CommandType = CommandType.StoredProcedure;
>> try
>> {
>> cnnConnection.Open();
>> cmdCommand.Transaction = cnnConnection.BeginTransaction();
>> cmdCommand.Parameters.Add("iRetorno", OleDbType.Integer, 32).Value = 4;
>> cmdCommand.Parameters["@iRetorno"].Direction = ParameterDirection.Output; --> this is generating error: Variable Q0P0 is not found
>> dx.SelectCommand = cmdCommand;
>> int nreg = dx.Fill(dt);
>> //ax =cmdCommand.ExecuteScalar();
>> //MessageBox.Show("Retornado: ? " + ax.ToString());
>> cnnConnection.Close();
>> }
>> catch (Exception Ex)
>> {
>> MessageBox.Show(Ex.Message);
>> }
>> }
>>
>>this is the stored procedure in my database:
>>
>>PROCEDURE test
>>PARAMETERS iRetorno as Integer
>>CLOSE TABLES ALL
>>SELECT * FROM class1 WHERE pkeyclass1="0O70WYR5U8" INTO CURSOR query1
>>iRetorno=444 &&dummy number to see if it is changed when "returning" to C#
>>RETURN SETRESULTSET("query1")
>>ENDPROC
>>
>>I need both, the resultset and the variable, the resultset is working fine but the parameter output that i need to be changed on the procedure and returned to C# changed is not working. Any ideas?
>>T.I.A.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only