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.
精彩评论