VB 6.0 (有代码)判断数据库中有无重复数据。急
DimConnAsNewADODB.ConnectionDimRsAsNewADODB.RecordsetConnstr="Provider=Microsoft.Jet....
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\Hydata.mdb" & ";Mode=ReadWrite;Persist Security Info=False"
Conn.Open Connstr
Conn.Execute "Select AdminUser from Admin Where AdminUser='" & User & "' "
If Not Rs.EOF Then
Rs.Clone
MsgBox "该用户名已存在,请重新输入!", vbExclamation + vbOKOnly, "提示!"
Admin_Name.Text = ""
Admin_Name.SetFocus
Else
Dim StrSql As String
StrSql = "insert into Admin (AdminUser,AdminPassWord,AdminSex,AdminMobileTel,AdminHomeTel,AdminAddress) Values ('" & Admin_Name.Text & "','" & Admin_PassWord.Text & "','" & Admin_Sex.Text & "','" & Admin_MobileTel.Text & "','" & Admin_HomeTel.Text & "','" & Admin_Address.Text & "')"
Conn.Execute StrSql
Conn.Close
Rs.Open
MsgBox "用户添加成功,请返回!", vbExclamation + vbOKOnly, "提示!"
Admin_Name.Text = ""
Admin_PassWord.Text = ""
Admin_RegPassWord = ""
Admin_MobileTel.Text = ""
Admin_HomeTel.Text = ""
Admin_Address.Text = ""
DgdAdminNew.Refresh
End If 展开
Dim Rs As New ADODB.Recordset
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\Hydata.mdb" & ";Mode=ReadWrite;Persist Security Info=False"
Conn.Open Connstr
Conn.Execute "Select AdminUser from Admin Where AdminUser='" & User & "' "
If Not Rs.EOF Then
Rs.Clone
MsgBox "该用户名已存在,请重新输入!", vbExclamation + vbOKOnly, "提示!"
Admin_Name.Text = ""
Admin_Name.SetFocus
Else
Dim StrSql As String
StrSql = "insert into Admin (AdminUser,AdminPassWord,AdminSex,AdminMobileTel,AdminHomeTel,AdminAddress) Values ('" & Admin_Name.Text & "','" & Admin_PassWord.Text & "','" & Admin_Sex.Text & "','" & Admin_MobileTel.Text & "','" & Admin_HomeTel.Text & "','" & Admin_Address.Text & "')"
Conn.Execute StrSql
Conn.Close
Rs.Open
MsgBox "用户添加成功,请返回!", vbExclamation + vbOKOnly, "提示!"
Admin_Name.Text = ""
Admin_PassWord.Text = ""
Admin_RegPassWord = ""
Admin_MobileTel.Text = ""
Admin_HomeTel.Text = ""
Admin_Address.Text = ""
DgdAdminNew.Refresh
End If 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询