VB6 and ASP 制作管理系统1--制作添加用户(3)
上次说到,登录之后,卸载登录窗口,然后显示管理界面;
界面随便设计吧.
窗体图如下,随便画的,有点乱。将就看吧,能知道用什么控件就行了!
只需要在Command1按钮处添加代码即可:
添加用户,用到 两个Text控件,一个Command控件。
Text控件分别命名为:txtUser,txtPass
双击Command1 添加如下代码:
呵呵,习惯了ASP的写法,
也可以直接用:conn.Execute("inst语句直接插入")
1 Private Sub Command1_Click()
2 '添加用户
3 Dim tuser
4 Dim tpass
5 tuser = Trim$(txtUser.Text)
6 tpass = Trim$(txtPass.Text)
7
8 If tuser = "" Then
9 MsgBox "用户名不可为空"
10 txtUser.SetFocus
11 Exit Sub
12 End If
13 If tpass = "" Then
14 MsgBox "密码不可为空"
15 txtPass.SetFocus
16 Exit Sub
17 End If
18
19 '打开数据库连接
20 Call OpenConn
21 sql = "select * from vuinfo"
22 rs.Open sql, conn, 1, 3
23 rs.AddNew
24 rs.Fields("username") = tuser
25 rs.Fields("password") = tpass
26 rs.Fields("userPower") = 0
27 rs.Update
28 '关闭数据库连接
29 Call CloseConn
30
31 MsgBox "添加用户成功"
32 txtUser.Text = ""
33 txtPass.Text = ""
34 txtUser.SetFocus
35 End Sub
2 '添加用户
3 Dim tuser
4 Dim tpass
5 tuser = Trim$(txtUser.Text)
6 tpass = Trim$(txtPass.Text)
7
8 If tuser = "" Then
9 MsgBox "用户名不可为空"
10 txtUser.SetFocus
11 Exit Sub
12 End If
13 If tpass = "" Then
14 MsgBox "密码不可为空"
15 txtPass.SetFocus
16 Exit Sub
17 End If
18
19 '打开数据库连接
20 Call OpenConn
21 sql = "select * from vuinfo"
22 rs.Open sql, conn, 1, 3
23 rs.AddNew
24 rs.Fields("username") = tuser
25 rs.Fields("password") = tpass
26 rs.Fields("userPower") = 0
27 rs.Update
28 '关闭数据库连接
29 Call CloseConn
30
31 MsgBox "添加用户成功"
32 txtUser.Text = ""
33 txtPass.Text = ""
34 txtUser.SetFocus
35 End Sub