开发者

VS2010 asp.net: executing parameter less stored proc to update record

I would like to execute a stored proc that simply updates a record. At this point I would like to keep it parameter less. But in future, I will be adding parameters to the stored proc. Can I simply do it via SQLDataSource? It will save me writing few lines of code to execute stored proc in a traditional ado.ne开发者_如何学编程t. If its possible, could you please supply me with a sample code?

Thanks


You could use System.Data.SqlClient.SqlCommand

Something like this...

SqlCommand command = new SqlCommand("p_UpdateSomething",  connectionstring);
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();

or using a SqlDataSource like

<asp:SqlDataSource id="sqlDS" runat="server" UpdateCommand="pUpdateSomething" UpdateCommandType="StoredProcedure"></asp:SqlDataSource>

Update parameters can be added to the SqlDataSource.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜