I have the following code:
Private Sub autogenerated()
Dim connStr As String = ConfigurationManager.ConnectionStrings("SY_InventoryConnectionString").ConnectionString
Dim str As String
Dim com As SqlCommand
Dim count As Integer
Dim con As New SqlConnection(connStr)
str = "select count(*) from Customer"
com = New SqlCommand(Str, con)
con.Open()
count = Convert.ToInt16(com.ExecuteScalar()) + 1
txtcustid.Text = "000000" + count.ToString()
txtcustid.Enabled = False
con.Close()
End Sub
I want when i try to insert to database let the code check if custid already exist