title: asp.net check is primary key exists before inserting into table
body: <p>looking for a simple way to check if a primary key already exists in the table before inserting into it. where Fname is the primary key in the table.</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(connStr);
  conn.Open();
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = conn;
  cmd.CommandText = "INSERT INTO [table] ([firstName], [lastName]) VALUES ('" + txtFName.Text + "','" + txtLName.Text + "')";        
  
  cmd.ExecuteNonQuery();
  conn.Close();
  </code></pre>