try {
string connectionstring = @"your_connection_string";
using(SqlConnection connection = new SqlConnection(connectionstring)) {
connection.Open();
string query = string.Format("insert into Employee values('{0}','{1}')", txtEmailId.Text, txtFullName.Text);
using(SqlCommand command = new SqlCommand(query, connection)) {
command.ExecuteNonQuery();
}
}
}
catch(SqlException ex) {
if (ex.Number == 2627) {
Response.Write("This is the primary key violation");
return;
}
else {
Response.Write("This is the general error");
return;
}
}