插入了一条记录,提示有重复 但还是插进了数据库,是怎么回事啊
If rs.RecordCount > 0 Then
MsgBox "登陆名已经存在!", vbOKOnly + vbExclamation, "警告!"
TxtLoginName.SetFocus
rs.Close
DataGridLogin.Refresh
Else
Adodc1.Recordset.Update
Adodc1.Refresh
If rs.RecordCount > 0 Then
MsgBox "登陆名已经存在!", vbOKOnly + vbExclamation, "警告!"
TxtLoginName.SetFocus
rs.Close
DataGridLogin.Refresh
Else
Adodc1.Recordset.Update
Adodc1.Refresh
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ..............."
cn.CursorLocation = adUseClient
cn.Open
Dim str As String
str = "select * from login where loginName='" & Trim(TxtLoginName) & "'"
rs.Open str, cn
If rs.RecordCount > 0 Then
MsgBox "登陆名已经存在!", vbOKOnly + vbExclamation, "警告!"
TxtLoginName.SetFocus
rs.Close
Else
Adodc1.Recordset.Update
Adodc1.Refresh
DataGridLogin.Refresh
偶从不用数据库件,都是 adodb.recordset 对象,操作起来灵活一些。
MsgBox "登陆名已经存在!", vbOKOnly + vbExclamation, "警告!"
TxtLoginName.SetFocus
rs.Closeadodc1.Recordset.CancelUpdateelse
....