15-10-18, 11:06 PM
VB6 :
VB.net :
PHP كود :
If rs.State = adStateOpen Then rs.Close
rs.Open "SELECT * FROM [information ] WHERE [NomBook ]=" & Trim$(Text1.Text) & _
"", db, adOpenStatic, adLockOptimistic
If rs.RecordCount <> 0 Then
MsgBox "record exists", vbCritical + vbOKOnly + vbMsgBoxRight, "Error"
Exit Sub
Else
' Put your add record here
End If
VB.net :
PHP كود :
If TextBox1.Text = "" Then
MsgBox("Please fill-up all fields!", MsgBoxStyle.Exclamation, "Add New Customer!")
Else
Dim theQuery As String = "SELECT * FROM information WHERE NomBook =@NomBook"
Dim cmd1 As SqlCommand = New SqlCommand(theQuery, con)
cmd1.Parameters.AddWithValue("@NomBook", TextBox1.Text)
Using reader As SqlDataReader = cmd1.ExecuteReader()
If reader.HasRows Then
' record already exists
MsgBox("record exists!", MsgBoxStyle.Exclamation, "Add New User!")
Else
' record does not exist,
' add code here
End If
End Using
con.Close()
