3

My question: is there any way to run multiple stored procedures with one SqlDataAdapter like this

adapter = new SqlDataAdapter("ProcforselectUserTableWhere ; ProcforselectuserTypeAuthorizationWhere", con);
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
adapter.SelectCommand.Parameters.AddWithValue("@Userid", Request.QueryString[0]);  
adapter.Fill(dataset);

I tried this but I am getting the error:

Could not find stored procedure 'ProcforselectUserTableWhere ; ProcforselectuserTypeAuthorizationWhere'.

Please help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Saveen
  • 702
  • 2
  • 14
  • 34
  • 1
    You'll need to make it into a SQL Command instead with multiple EXEC's and then add your own explicit parameters. Or else write a stored procedure to do it. – RBarryYoung Dec 19 '13 at 13:10

1 Answers1

3

No, this is not possible because stored procedures are executed differently than raw SQL statements. See, the parameters are implied with stored procedures, not defined in the query. Therefore the Fill method is looking for a stored procedure that is literally named in the CommandText.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232