I was mentally retarded when I logged on as a user today ......
---------------------------------------------------------------------------------
Tip:
A Password error is always prompted during logon,
Print IIF (TRIM (Rs. Fields ("password") = password, "equal", "not equal ")
It took a long time to find out:
When designing a database for SQL2000, the string in the field should be designed as a variable length (varchar ),
If it is designed to be a char with a fixed length, the database will automatically fill in space if your string is not long enough.
---------------------------------------------------------------------------------
VB6-> Add a form-> Save As login. FRM
Add two labels:
Lable1.caption = "User name :"
Lable2.caption = "Password :"
Add two text boxes:
Name text1 txtuser
Name text2 txtpass
The login. frm code is as follows:
1 'user logon code
2 Public sub userlogin ()
3
4 If txtuser. Text = "" then
5 msgbox "user name cannot be blank"
6. txtuser. setfocus
7 exit sub
8 end if
9 If txtpass. Text = "" then
10 msgbox "the password cannot be blank"
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' determine whether a user exists
23 if Rs. EOF then
24 msgbox "the user name does not exist"
25 txtuser. setfocus
26 call closeconn
27 exit sub
28 end if
29' determine the user password
30 if Rs. Fields ("password") <> password then
31 msgbox "Incorrect password"
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 'uninstall login form
41 end if
42 end sub