VB6 and ASP 製作管理系統1–VB6製作使用者登入

來源:互聯網
上載者:User

今天做使用者登入的時候,智障了……

---------------------------------------------------------------------------------

友情提示:

登入的時候總提示密碼錯誤,

Print IIf(Trim(rs.Fields("password")) = password, "相等", "不相等")

找了好久,才發現:

SQL2000 設計資料庫的時候,欄位中,字串要設計成可變長度(varchar),

如果設計成char固定長度,那麼,如果你的字串不夠長度,資料庫會自動用空格補齊。

---------------------------------------------------------------------------------

 VB6—>填加表單—>儲存為Login.frm

添加兩個標籤:

lable1.Caption="使用者名稱:"

lable2.Caption="密碼:"

添加兩個文字框:

 text1命名為txtUser

 text2命名為txtPass

 

Login.frm代碼如下:

 1 '使用者登入代碼
 2 Public Sub userlogin()
 3 
 4     If txtUser.Text = "" Then
 5         MsgBox "使用者名稱不可為空白"
 6         txtUser.SetFocus
 7         Exit Sub
 8     End If
 9     If txtPass.Text = "" Then
10         MsgBox "密碼不可為空白"
11         txtPass.SetFocus
12         Exit Sub
13     End If
14     
15     username = Trim(txtUser.Text)
16     password = Trim(txtPass.Text)
17     
18     Call OpenConn
19     
20     sql = "select * from vuinfo where username='" & username & "'"
21     rs.Open sql, conn, 1, 1
22     '判斷使用者是否存在
23     If rs.EOF Then
24        MsgBox "使用者名稱不存在"
25        txtUser.SetFocus
26        Call CloseConn
27        Exit Sub
28     End If
29     '判斷使用者密碼
30     If rs.Fields("password") <> password Then
31         MsgBox "密碼錯誤"
32         Call CloseConn
33         Exit Sub
34         Else
35         username = rs.Fields("username")
36         password = rs.Fields("password")
37         userPower = rs.Fields("userPower")
38         Call CloseConn
39         infop.Show '顯示管理介面
40         Unload Login '卸載登入表單
41     End If
42 End Sub

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.