public string Insert(InsertUser user) { string msg; SqlConnection con = new SqlConnection("Data Source=LAPTOP-E77BQ7S0;Initial Catalog=WcfService2;User ID=sa;Password=123;Pooling=False"); con.Open(); SqlCommand cmd = new SqlCommand("Insert into UserTab (Name, Email) values(@Name, @Email)", con); cmd.Parameters.AddWithValue("@Name", user.Name); cmd.Parameters.AddWithValue("@Email", user.Email); int g = cmd.ExecuteNonQuery(); if (g == 1) { msg = "Successfully Inserted"; } else { msg = "Failed to insert"; } return(msg); }
public string Insert(InsertUser user) { string msg; SqlConnection con = new SqlConnection("Data Source=DESKTOP-M66THJ5;Initial Catalog=MyTestDB;Persist Security Info=True;User ID=sa;Password=12345;Pooling=False"); con.Open(); SqlCommand cmd = new SqlCommand("Insert into UserTab (Name, Email) values(@Name, @Email)", con); cmd.Parameters.AddWithValue("@Name", user.Name); cmd.Parameters.AddWithValue("@Email", user.Email); int g = cmd.ExecuteNonQuery(); if (g == 1) { msg = "Successfully Inserted"; } else { msg = "Failed to insert"; } return(msg); }