locked
can ParameterDirection.InputOutput apply to only input parameter? RRS feed

  • Question

  • can ParameterDirection.InputOutput apply to only input parameter?

    for example

    original is

    @BatchID int output, <- extract from stored procedure

    defaultDB.AddParameter(command, "BatchID", DbType.Int32, ParameterDirection.InputOutput, string.Empty, DataRowVersion.Current, Batchid);

    can ParameterDirection.InputOutput also apply to

    @BatchID int,

     


    Hello
    Monday, June 27, 2011 4:17 AM

Answers

  • I wrote a code which i want. However, for multiple output, there is need dynamic. As there is no information about member is output or not, i write a function to tell it whether is output in stored procedure,

    Originally, fillinparameters function and getreturnvalue written in object class. Now i can remove them from class object.


    Hello


    • Marked as answer by 沈世鈞 Wednesday, June 29, 2011 3:04 AM
    • Unmarked as answer by 沈世鈞 Wednesday, June 29, 2011 3:13 AM
    • Marked as answer by 沈世鈞 Thursday, June 30, 2011 5:22 AM
    Wednesday, June 29, 2011 2:57 AM

All replies

  • Hi!

    First of all, this is the Entity Framework forum, I would advice you to post non-EF related ADO.NET questions on ADO.NET Managed Providers forum, since this is more specific for your questions.

    However, Since the @BatchID is an output parameter, you should use ParameterDirection.Output to define it since you wont be able to send anything in to the parameter anyway.

     


    --Rune
    • Marked as answer by 沈世鈞 Wednesday, June 29, 2011 2:57 AM
    • Unmarked as answer by 沈世鈞 Wednesday, June 29, 2011 3:14 AM
    Monday, June 27, 2011 6:32 AM
  • In MS access application, i see that there is code direction.inputouput for this output parameter
    Hello
    Monday, June 27, 2011 7:03 AM
  • Hi,

    And ? Could you be more explicit ? If you meant this is unexpected you could switch to Output and see if it still works. Not sure with Access but you are allowed to use the same parameter both to provide a value, do some calculation and return the value using the same parameter (InputOutput).

    Or perhaps are you confused because you think the provider would enforce this ? IMO this is just a hint. If you use an InputOutput parameter but you are not using the input value inside your procedure, the provider has no way to know about that.

    So this is likely just a shortcoming in the code you could fix to make clear to readers that this parameter value is not used as an input value by the stored proc.


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".
    Monday, June 27, 2011 12:51 PM
  • I wrote a code which i want. However, for multiple output, there is need dynamic. As there is no information about member is output or not, i write a function to tell it whether is output in stored procedure,

    Originally, fillinparameters function and getreturnvalue written in object class. Now i can remove them from class object.


    Hello


    • Marked as answer by 沈世鈞 Wednesday, June 29, 2011 3:04 AM
    • Unmarked as answer by 沈世鈞 Wednesday, June 29, 2011 3:13 AM
    • Marked as answer by 沈世鈞 Thursday, June 30, 2011 5:22 AM
    Wednesday, June 29, 2011 2:57 AM