Vijay

Vijay

  • NA
  • 150
  • 89.3k

SQL Command type

Aug 1 2013 1:56 AM

I create an stored procedure like dis....

CREATE PROCEDURE sp_Personal
@ID int,@Name varchar(50)@Gender varchar(6),@Address varchar(75),
@Phone bigint,@Status varchar(15)
AS
BEGIN
IF @Status='Create'
BEGIN
INSERT INTO Student1(Name,Gender,Address,Phone) VALUES
(@Name,@Gender,@Address,@Phone)
END
IF @Status='Update'
BEGIN
UPDATE Student1 SET Name=@NameGender=@Gender,Address=@Address,Phone=@Phone
WHERE ID=@ID
END
END



Now my issue is want to connect to frontend usind ADO.net

public Create(Personal pers)
{
 SqlConnection con = new SqlConnection("Data Source=SamplePC;Initial Catalog=Sample;Integrated Security=True");
SqlCommand com = new SqlCommand("sp_Personal", con);
com.CommandType = CommandType.StoredProcedure;

}


How to call a "Create" query  only using Status parameter in frontend. am using MVC4 asp.net

Answers (11)