[求助]一段程序问题?数据库相关
Private Sub Command1_Click()Dim conn As New ADODB.Connection
Dim rs_add As New ADODB.Recordset
Dim sql As String
If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "警告!"
Me.Text1.SetFocus
Exit Sub
End If
sql = "select * from 系统管理"
rs_add.Open sql, conn, adpenkeyset, adLockPessimistic
While (rs_add.EOF = False)
If Trim(rs_add.Fields(0)) = Trim(Text1.Text) Then
MsgBox "已经有这个用户了!", vbOKOnly + vbexclamatin, ""
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
rs_add.MoveNext
End If
Wend
If Trim(Text2.Text) = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告!"
Me.Text2.SetFocus
Exit Sub
End If
If Trim(Me.Text2) <> Trim(Me.Text3) Then
MsgBox "两次密码不一致!", vbOKOnly + vbExclamation, "警告!"
Me.Text2 = ""
Me.Text3 = ""
Me.Text2.SetFocus
Exit Sub
End If
rs_add.AddNew
rs_add.Fields(0) = Trim(Me.Text1)
rs_add.Fields(1) = Trim(Me.Text2)
rs_add.Update
rs_add.Close
End Sub
实时错误
连接无法用于此操作,在此上下文中它可能被关闭或无效
打开文件在启动窗口中呢!
[[italic] 本帖最后由 wwhhjj 于 2007-12-6 10:54 编辑 [/italic]]