I have a table name AVUKAT and it's columns (`AVUKAT`, `HESAP`(Primary KEY), `MUSTERI`)

All `MUSTERI` has a one unique `HESAP` (int).

Simple I have a page like this.

![enter image description here](https://i.stack.imgur.com/VI8gZ.jpg)

First dropdown is selected MUSTERI, second is AVUKAT

And i automaticly calculating HESAP (`int` and `Primary KEY`) with this code. (On the background.)

```
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string strConnectionString = ConfigurationManager.ConnectionStrings["SqlServerCstr"].ConnectionString;

        SqlConnection myConnection = new SqlConnection(strConnectionString);
        myConnection.Open();
        string hesapNo = DropDownList1.SelectedItem.Value;

        string query = "select A.HESAP_NO from YAZ..MARDATA.S_TEKLIF A where A.MUS_K_ISIM = '" + hesapNo + "'";

        SqlCommand cmd = new SqlCommand(query, myConnection);

        if (DropDownList1.SelectedValue != "0" && DropDownList2.SelectedValue != "0")
        {
            Add.Enabled = true;
            Label1.Text = cmd.ExecuteScalar().ToString();
        }
        else
        {
            Add.Enabled = false;

        }
        Label1.Visible = false;
        myConnection.Close();
    }

```

I just calculating `HESAP` with this code.

And my `ADD` button click function is;

```
protected void Add_Click(object sender, EventArgs e)
    {

        try
        {
            string strConnectionString = ConfigurationManager.ConnectionStrings["SqlServerCstr"].ConnectionString;

            SqlConnection myConnection = new SqlConnection(strConnectionString);
            myConnection.Open();

            string hesap = Label1.Text;
            string musteriadi = DropDownList1.SelectedItem.Value;
            string avukat = DropDownList2.SelectedItem.Value;

            SqlCommand cmd = new SqlCommand("INSERT INTO AVUKAT VALUES (@MUSTERI, @AVUKAT, @HESAP)", myConnection);

            cmd.Parameters.AddWithValue("@HESAP", hesap);
            cmd.Parameters.AddWithValue("@MUSTERI", musteriadi);
            cmd.Parameters.AddWithValue("@AVUKAT", avukat);
            cmd.Connection = myConnection;

            SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
            Response.Redirect(Request.Url.ToString());
            myConnection.Close();
        }
        catch (Exception)
        { 
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), " ", "alert('Bu Müşteri Zaten Mevcut!')", true);

        }
    }

```

The reason use `try catch` , if anybody try to add add with same HESAP (int) value for the MUSTERI i want show an error message and don't add the table.

But when i try to add same MUSTERI (also same HESAP) adding same MUSTERI with HESAP=0 value.

![enter image description here](https://i.stack.imgur.com/MUZLx.jpg)

How can i prevent this situation? I select HESAP column is Primary KEY, but still add same MUSTERI.