CREATE PROCEDURE RegionUpdate
(
@RegionID int,
@RegionDescription nvarchar(100)
)
AS
BEGIN
SET NOCOUNT ON;
Update Region set RegionID=@RegionID,RegionDescription=@RegionDescription where RegionID=23;
END
GO
/**************************************************************************************************/
CREATE PROCEDURE RegionDelete
(
@RegionID int
)
AS
BEGIN
SET NOCOUNT ON;
delete from Region where RegionID=@RegionID;
END
GO
/*****************************************************************************************/
CREATE PROCEDURE RegionInsert
(
@RegionID int,
@RegionDescription nvarchar(100)
)
AS
BEGIN
SET NOCOUNT ON;
insert into Region(RegionID,RegionDescription) values(@RegionID,@RegionDescription);
END
GO
/****************************************************************************************/
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5
{
class Program
{
static void Main(string[] args)
{
SqlConnection con = null;
try
{
string source = "server=.;uid=sa;pwd=Server2012;database=D:\\DATABASE\\NORTHWND.MDF";
con = new SqlConnection(source);
SqlCommand cmd = new SqlCommand("RegionDelete", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@RegionID", 23);
cmd.Parameters.AddWithValue("@RegionDescription", "guangdong");
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
con.Close();
}
}
}
}