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

标签 c# asp.net .net sqldataadapter

我的问题:有没有办法像这样用一个 SqlDataAdapter 运行多个存储过程

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

我试过了,但出现错误:

Could not find stored procedure 'ProcforselectUserTableWhere ; ProcforselectuserTypeAuthorizationWhere'.

请帮忙

最佳答案

不,这是不可能的,因为存储过程的执行方式与原始 SQL 语句不同。请看,参数隐含在存储过程中,未在查询中定义。因此,Fill 方法正在寻找在 CommandText 中按字面命名的存储过程。

关于c# - 使用一个 SqlDataAdapter 运行多个存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20682316/

相关文章:

c# - WPF 应用程序中的颠倒浏览器

c# - 将 MemberInitExpression 分配给属性的 ExpressionTree 方法

c# - 在 Razor 页面中动态更改按钮标签文本

c# - WebClient.UploadFileASync 的非常奇怪的行为

c# - 单击按钮时使用 JS 更改 asp :HiddenField. 值

asp.net - ASP Core Azure Active Directory 登录使用角色

c# - 如何使用 LINQ 和 Entity Framework 6 进行表连接?

c# - 当服务器关闭 keep-alive http 连接时检测或避免客户端 CommunicationException

.net - 如何使用 JSON.NET 在 BSON 中将 GUID 序列化为 native UUID

c# - 将主体添加到应该被覆盖的虚拟方法