Home > Software engineering >  [for] VB6.0 by use production logging system
[for] VB6.0 by use production logging system

Time:12-22

think before do login system is too unsafe, then, is a little more to learn database programming
database called xiaowenwen, called User data table, there are two items, one is a UserName, a PassWord is

 Dim cn As New ADODB. Connection 
Dim the rs As New ADODB. You
Dim Strcn As String
Strcn="Driver={MySQL ODBC 3.51 Diver}; Server=this is IP; The Database=xiaowenwen; Uid=xiaowenwen; The PWD=xiaowenwen; Option=3; STMT=Set Names GB2312 "
Cn. Open Strcn
Cn. CursorLocation=adUseClient
Rs. Open "User", cn, adOpenKeyset, adLockOptimistic
But, I want to read data table of the UserName and PassWord, how to write here
Rs. Close
Cn. Close

I have two Text, Text1. The Text is a user name (UserName), Text2. The Text is the PassWord (PassWord), how can I get to use data table to do the login system, please complete code

CodePudding user response:

Rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; "'", cn, adOpenKeyset, adLockOptimistic
If the rs! X=0 then
Logon failure
The else
Log in successfully
end if

CodePudding user response:

Learn about the SQL syntax,
The select, update, insert, delete
The four most basic,

CodePudding user response:

reference 1st floor caozhy response:
rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; "'", cn, adOpenKeyset, adLockOptimistic
If the rs! X=0 then
Logon failure
The else
Log in successfully
End the if


This is a very unsafe way of query,

Code was meant, if the user input 'Bob' and '1234', the code will get the following SQL statement:
SELECT COUNT (*) AS the FROM x [User] WHERE the username='Bob' AND password='1234'

But a cheater can enter in the password box 'OR' 0 '=' 0, the user name don't need to care about, even can not input, get the SQL statements are as follows:
SELECT COUNT (*) AS the FROM x [User] WHERE the username='AND password=' OR '0'='0'

Because '0'='0' is true forever, so the query can be recorded, which means the login successfully!

Safe, it is only in view of the user name query its password, and then in the code to compare the password,

CodePudding user response:

reference of123 reply: 3/f
Quote: refer to 1st floor caozhy response:

Rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; "'", cn, adOpenKeyset, adLockOptimistic
If the rs! X=0 then
Logon failure
The else
Log in successfully
End the if


This is a very unsafe way of query,

Code was meant, if the user input 'Bob' and '1234', the code will get the following SQL statement:
SELECT COUNT (*) AS the FROM x [User] WHERE the username='Bob' AND password='1234'

But a cheater can enter in the password box 'OR' 0 '=' 0, the user name don't need to care about, even can not input, get the SQL statements are as follows:
SELECT COUNT (*) AS the FROM x [User] WHERE the username='AND password=' OR '0'='0'

Because '0'='0' is true forever, so the query can be recorded, which means the login successfully!

Safe, it is only in view of the user name query its password, and then in the code to compare the password,

what

CodePudding user response:

reference 1st floor caozhy response:
rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; "'", cn, adOpenKeyset, adLockOptimistic
If the rs! X=0 then
Logon failure
The else
Log in successfully
End the if

by the way, how registration system
 rs. Open the "select count (*) as X from ` User ` where ` username `=text1. Text, cn, adOpenKeyset, adLockOptimistic 
If the rs! X=0 then
This is the registration statement
End the If

/b so can? [/b]

CodePudding user response:

reference 5 floor qq_23284487 reply:
Quote: refer to 1st floor caozhy response:

Rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; "'", cn, adOpenKeyset, adLockOptimistic
If the rs! X=0 then
Logon failure
The else
Log in successfully
End the if

by the way, how registration system
 rs. Open the "select count (*) as X from ` User ` where ` username `=text1. Text, cn, adOpenKeyset, adLockOptimistic 
If the rs! X=0 then
This is the registration statement
End the If

this can?

note: the registration window, Text1. The Text is the user name, Text2. The Text is the password, the process is that the first to determine whether the user name exists, if there is no write data

CodePudding user response:

reference 4 floor qq_23284487 response:
Quote: reference of123 reply: 3/f

Quote: refer to 1st floor caozhy response:

Rs. Open the "select count (*) as X from ` User ` where ` username `='" & amp; Text1. Text & amp; "' and ` password `='" & amp; Text2. Text & amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related