I am programming in Visual Basic with database in SQL Server, and I can not do that when inserting a new record in the database, do not let me do it if the following conditions are repeated:
For example, if I enter a record with the following data:
Numero: 1, Año:2017 y Modelo: A
enter it, but do not enter it if all the data are repeated, unless one of them changes ... for example, that the number is still 1
and model A
, but that the year is 2018
, if you enter it.
I have the following code, pro only works for 1 condition, in this case the number, but it does not help me to prevent it from registering with the 3 conditions ( numero
, año
and modelo
):
SQL = "SELECT COUNT(*) FROM registros WHERE numerodoc = '" & tbxNumDoc.Text & "''"
Com = New SqlCommand(SQL, MiConexion)
Rs = Com.ExecuteReader() Rs.Read()
lblBuscaNumDoc.Text = Rs(0)
Rs.Close()
MiConexion.Close()
If lblBuscaNumDoc.Text = 0 Then
conectar.sqlconecta()
conectar.creadocumento()