| |

VerySource

 Forgot password?
 Register
Search
View: 5|Reply: 3

Add user issue on login interface

[Copy link]

3

Threads

7

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-3-21 01:00:01
| Show all posts |Read mode
I made a login interface, clicked the add user button, and added the user, but I entered the login box into the login box, and an error occurred, saying that the database does not have this user field. After I closed the program and re-run it, I could log in again. Why can't I log in directly after adding, my code is as follows.
Add button code: procedure checkinput (theedit: tedit; strdesc: string);
    begin
       theedit.Text: = trim (theedit.Text);
       theedit.Text: = stringreplace (theedit.Text, `` '', '', [rfreplaceall]);
       theedit.Text: = stringreplace (theedit.Text, '', '', [rfreplaceall]);
       if theedit.Text = '' then
         begin
             showmessage (strdesc);
             theedit.SetFocus;
             abort;
         end;
    end;
begin
     checkinput (edit1, 'Please enter an operator name!');
     checkinput (edit2, 'Please enter your password!');

    with query1 do
    begin
        active: = false;
        sql.Clear;

        sql.Add ('insert into users (username, passwd)');
        sql.Add ('values ​​((: a), (: b))');
        params [0] .AsString: = edit1.Text;
        params [1] .AsString: = edit2.Text;

        execSQL;


    end;

    showmessage ('Added successfully!');
    edit1.Clear;
    edit2.Clear;

Login button code:
 procedure checkinput (theedit: tedit; strdesc: string);
  begin
     theedit.Text: = trim (theedit.Text);
     theedit.Text: = stringreplace (theedit.Text, `` '', '', [rfreplaceall]);
     theedit.Text: = stringreplace (theedit.Text, '', '', [rfreplaceall]);
     if theedit.Text = '' then
     begin
        showmessage (strdesc);
        theedit.SetFocus;
        abort;
     end;
  end;
begin

   checkinput (edtusername, 'Please enter an operator name!');
   checkinput (edtPasswd, 'Please enter a password!');
   query1.Active: = false;
   query1.ParamByName ('UserName'). AsString: = edtusername.Text;
   query1.ParamByName ('passwd'). AsString: = edtpasswd.Text;
   query1.Active: = true;
   if query1.Eof then
   begin
     showmessage ('The operator name or password is incorrect!');
     edtusername.SetFocus;
     inc (times);
   end
   else
       modalresult: = mrOK;
   if times> = 3 then
   begin
      showmessage ('Illegal user is not authorized to log in!');
      modalresult: = mrcancel;
   end;
Reply

Use magic Report

0

Threads

46

Posts

25

Credits

Newbie

Rank: 1

Credits
25

 China

Post time: 2020-6-28 13:45:01
| Show all posts
This phenomenon is obviously the problem that the data refresh is not timely. It is recommended that you refresh the query during login verification!
Reply

Use magic Report

3

Threads

7

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

 Author| Post time: 2020-6-30 01:45:02
| Show all posts
That should be how to add refresh code in the above code, please say, thank you
Reply

Use magic Report

0

Threads

46

Posts

25

Credits

Newbie

Rank: 1

Credits
25

 China

Post time: 6 day(s) ago
| Show all posts
query1 re-exesql
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list