1,216
社区成员
发帖
与我相关
我的任务
分享
Private Sub cmd_add_Click()
Dim cn As New ADODB.Connection
Dim dr As New ADODB.Recordset
If Len(newuser.Text) = 0 Or Len(pass.Text) = 0 Or Len(pass2.Text) = 0 Then '判断用户名密码是否为空
MsgBox "用户或密码不能为空", vbOKOnly + 32, "注意!" '判断用户名密码是否为空
Else
On Error Resume Next
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" _
& App.Path & "\MISER.mdb;Mode=ReadWrite;Persist Security Info=True;Jet OLEDB:Database Password=lsj123000"
dr.Open "select 用户名 from user1 where 用户名='" & newuser.Text & "'", cn, 1, 1 '判断用户名是否存
If dr.EOF Then '判断用户名是否存
cn.Execute "select 用户名 from user1 where 用户名='" & newuser.Text & "'" '判断用户名是否存
Dim B
B = 1
Set Count1 = ExeCutesql("select * from user1 ", Str_text)
Count1.MoveLast
B = Count1.Fields(3) + 1
ExeCutesql "insert into user1 values('" & newuser.Text & "','" & pass.Text & "','" & Format(DTPicker1.Value, "yyyy-mm-dd" & " " & Time) & "'," & B & ") ", Str_text
If pass.Text = pass2.Text Then
Call Db
Mydb.MoveLast
MsgBox "数据已经保存!", vbOKOnly + 64, "成功"
Else
MsgBox "两次密码不一样"
End If
Else
MsgBox "该用户已存在" '判断用户名是否存
End If
End If
End Sub