hello every one this is a sample code to Create and then all a sql stored procedure through ado.net code in C#.
here is the code to call the stored procedure.
public static void AddManufacturer(string Name, string Address, string City, string State, string PhoneNo) { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { using (SqlCommand command = new SqlCommand("AddManufacturer", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Name", Name)); command.Parameters.Add(new SqlParameter("@Address", Address)); command.Parameters.Add(new SqlParameter("@City", City)); command.Parameters.Add(new SqlParameter("@State", State)); command.Parameters.Add(new SqlParameter("@PhoneNo", PhoneNo)); connection.Open(); command.ExecuteNonQuery(); } } }
And this is the Stored Procedure code.
CREATE PROCEDURE AddManufacturer @Name nvarchar(50), @Address nvarchar(50), @City nvarchar(50), @State nvarchar(50), @PhoneNo nvarchar(50) AS INSERT INTO [Manufacturers] ([Name], [Address], [City], [State], [Ph No]) VALUES (@Name, @Address, @City, @State, @PhoneNo) RETURN
|
No responses found. Be the first to respond and make money from revenue sharing program.
|