Ciao. Dovrei inserire un dato in tabella solamente se non è già esistente, facendo così:
codice:
SqlDataAdapterNumPres.SelectCommand.CommandText = "SELECT TOP 1 * FROM PIN WHERE PIN = '" + tbNumeroTelefonico.Text + "'"
        SqlDataAdapterNumPres.Fill(DataSetNumPres)

        If DataSetNumPres.Tables(0).Rows.Count = 0 Then
            
            SqlCommand1.CommandText = "INSERT INTO PIN ecc...."

            SqlCommand1.Connection.Open()
            Try
                SqlCommand1.ExecuteNonQuery()
            Catch
                Response.Redirect("Errore.aspx")
                SqlCommand1.Connection.Close()
            End Try

            SqlCommand1.Connection.Close()
            tbNumeroTelefonico.Text = ""

        Else
            'stampo messaggio di errore
        End If
solo che inserisce comunque il numero. Dove sbaglio? grazie