【发布时间】:2014-12-09 13:51:15
【问题描述】:
我想运行两个不同的存储过程。列出的第一个将在启动时运行并显示数据库中的所有条目。第二个我只想在按下按钮时运行,它只显示特定条目。像这样运行它们可能不是最好的主意,但我已经尝试了一些不同的东西,到目前为止还没有运气。有什么建议吗?
<asp:SqlDataSource ID="sqlDevRequestHistory" runat="server" ConnectionString="<%$ ConnectionStrings:TrackIt %>"
SelectCommand="DevRequestHistory_SEL2" SelectCommandType="StoredProcedure" />
<asp:SqlDataSource ID="SqlDevReqestHistory" runat="server" ConnectionString="<%$ ConnectionStrings:TrackIt %>"
SelectCommand="DevRequestHistory_SEL" SelectCommandType="StoredProcedure" />
public void btnShowAll_Click(object sender, EventArgs e)
{
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["TrackIt"].ConnectionString))
{
using (var command = new SqlCommand("DevRequestHistory_SEL", connection))
{
command.CommandType = CommandType.StoredProcedure;
connection.Open();
command.ExecuteNonQuery();
}
}
}
【问题讨论】:
标签: c# asp.net stored-procedures sqldatasource