Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. CREATE PROCEDURE DeleteProduct @id nvarchar(100)
  2. AS
  3. BEGIN
  4. SET NOCOUNT ON;
  5. DELETE FROM Product WHERE product_id = @id;
  6. END;
  7.  
  8. public SqlCommand InitSqlCommand(string query, CommandType commandType)
  9. {
  10. var Sqlcommand = new SqlCommand(query, con);
  11. Sqlcommand.CommandType = commandType;
  12. return Sqlcommand;
  13. }
  14. public void ExecuteQuery(SqlCommand command)
  15. {
  16. con.Open();
  17. try
  18. {
  19. command.ExecuteNonQuery();
  20. }
  21. finally
  22. {
  23. con.Close();
  24. }
  25. }
  26. public void Delete()
  27. {
  28. string command = "DeleteProduct;";
  29. var query = Connection.InitSqlCommand(command, CommandType.StoredProcedure);
  30. query.Parameters.AddWithValue("@id", Id);
  31. Connection.ExecuteQuery(query);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement