上次說到,登入之後,卸載登入視窗,然後顯示管理介面;
介面隨便設計吧.
表單圖如下,隨便畫的,有點亂。將就看吧,能知道用什麼控制項就行了!
只需要在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