使用一个SqlDataAdapter运行多个存储过程

时间:2020-12-15 15:42:33

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

我的问题是:是否有办法使用一个SqlDataAdapter运行多个存储过程

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'.

无法找到存储过程的ProcforselectUserTableWhere;ProcforselectuserTypeAuthorizationWhere”。

Please help

请帮助

1 个解决方案

#1


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.

不,这是不可能的,因为存储过程的执行与原始SQL语句不同。请参见,这些参数是用存储过程表示的,而不是在查询中定义的。因此,Fill方法正在寻找一个在CommandText中按字面名称命名的存储过程。

#1


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.

不,这是不可能的,因为存储过程的执行与原始SQL语句不同。请参见,这些参数是用存储过程表示的,而不是在查询中定义的。因此,Fill方法正在寻找一个在CommandText中按字面名称命名的存储过程。