Results 1 to 2 of 2

Thread: SqlCommandBuilder.DeriveParameters

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    13

    SqlCommandBuilder.DeriveParameters

    Hi,
    When I use SqlCommandBuilder.DeriveParameter to derive the parameters of a stored procedure using a command object when it returns the parameter direction is being returned as InputOutput even though I have a stored procedure with an output parameter.Below is a sample code. In the stored procedure P_GET_SRITEST I have an Output Parameter.

    connection.Open();
    com = new SqlCommand();
    com.Connection = connection;
    com.CommandText = "P_Get_SRITEST";
    com.CommandType = CommandType.StoredProcedure;
    SqlCommandBuilder.DeriveParameters(com);
    Once the above code is executed if is examine the command object(com) the direction for the paramters is being shown as inputoutput instead of output.

    Any thoughts appreciated. Or is there any other way to detect parameters.

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    My first rule on CommandBuilders is, "Don't Use Them."
    While it is true that with simple SQL it is possible to get a reliable set of other command objects, it's quirky at best, and completely lazy....
    If you intend to use parameterized queries, I suggest you code the whole thing by hand. This gets better results when executing the Update method on your dataadapter and you as the programmer know exactly what the code you are executing looks like.
    As for the reason for the inputoutput type declaration, you have to pass in a variable and have it populated to get a value returned on an output paramter when executing a command that uses parameterized queries.

    Make sense?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width