Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE DeleteProduct @id nvarchar(100)
- AS
- BEGIN
- SET NOCOUNT ON;
- DELETE FROM Product WHERE product_id = @id;
- END;
- public SqlCommand InitSqlCommand(string query, CommandType commandType)
- {
- var Sqlcommand = new SqlCommand(query, con);
- Sqlcommand.CommandType = commandType;
- return Sqlcommand;
- }
- public void ExecuteQuery(SqlCommand command)
- {
- con.Open();
- try
- {
- command.ExecuteNonQuery();
- }
- finally
- {
- con.Close();
- }
- }
- public void Delete()
- {
- string command = "DeleteProduct;";
- var query = Connection.InitSqlCommand(command, CommandType.StoredProcedure);
- query.Parameters.AddWithValue("@id", Id);
- Connection.ExecuteQuery(query);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement