umair mohsin

umair mohsin

  • 1.3k
  • 356
  • 56.6k

REcord is not inserting as supplies

May 6 2017 4:34 AM
here is my stored procedure
 
CREATE PROCEDURE [dbo].[InsertRecord]
-- Add the parameters for the stored procedure here
@name varchar,
@gender varchar
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into Test values('@name','@gender');
END
 
here is my code behind
 
 
string constr = ConfigurationManager.ConnectionStrings["JPConstr"].ConnectionString.ToString();
SqlConnection conn = new SqlConnection(constr);
conn.Open();
SqlCommand cmd = new SqlCommand("InsertRecord", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name",TextBox1.Text);
cmd.Parameters.AddWithValue("@gender",TextBox2.Text);
cmd.ExecuteNonQuery();
Label2.Text = "Record inserted";
conn.Close();
 
record inserted in database like this
 
name=@name
gender=@gender
what is the problem with my code can anyone please tell 

Answers (2)