我一直输入相同的内容username
,但仍保存到DB中。我的代码有什么问题?
sql = "INSERT INTO testing_mysql_vb(id,user_name) VALUES(NULL,'" & TextBox1.Text & "')"
Try
dbcomm = New MySqlCommand(sql, dbconn)
dbread = dbcomm.ExecuteReader()
dbread.Close()
If dbread.HasRows Then
sql = "select from testing_mysql_vb where user_name = '" & TextBox1.Text & "'"
MsgBox("Duplicate record!")
End If
Catch ex As Exception
MsgBox("Error in saving to Database. Error is :" & ex.Message)
dbread.Close()
Exit Sub
End Try
MsgBox("The User Name was saved.")
TextBox1.Text = ""
我看到的可能是以下两个问题中的任何一个:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句