Recent

Author Topic: [HELP] Connecting to a SQL Database tables?- Console Application  (Read 33196 times)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #75 on: December 22, 2014, 03:05:32 pm »
Wow, thank you very much. How did you know that would fix the issue?

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #76 on: December 22, 2014, 03:06:56 pm »
Is there any way to make the password come up in *? This isn't to do with SQL databases. Just don't know how to approach this. Want it to display * instead of the text they're inputting :)

rvk

  • Hero Member
  • *****
  • Posts: 4329
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #77 on: December 22, 2014, 03:08:44 pm »
Wow, thank you very much. How did you know that would fix the issue?
Because I traced through the lines and it kept giving one record for user "test" even though the password was wrong. When using numbers (i.e. 2, 5, or 7 etc) the password check was correct. So the problem must have been the password-field... and indeed... after checking your table I saw you had int(50) (a 50 number integer)  :D

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #78 on: December 22, 2014, 03:11:17 pm »
You really know your stuff. Where did you learn everything? Youtube or college or??

Also~: Is there any way to make the password come up in *? This isn't to do with SQL databases. Just don't know how to approach this. Want it to display * instead of the text they're inputting :)

rvk

  • Hero Member
  • *****
  • Posts: 4329
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #79 on: December 22, 2014, 03:18:43 pm »
You really know your stuff. Where did you learn everything? Youtube or college or??
Just by doing it a lot. I've been doing it since 1990 so I've got enough practice  :)

Also~: Is there any way to make the password come up in *? This isn't to do with SQL databases. Just don't know how to approach this. Want it to display * instead of the text they're inputting :)
Mmm, for that you would need to write your own "readln" procedure. Readln itself doesn't provide hidden input. But you can use readkey. It reads a key without outputting anything to screen. That way (if put in a loop) you could build the input-string yourself and output a "*" for every character. (You've probably already used readkey in the game for capturing user-keys)

Code: [Select]
  procedure ReadLnSecret(var S:String);
  var
    c: char;
  begin
    s := '';
    repeat
      c := readkey;
      if c <> #13 then
      begin
        s := s + c;
        Write('*');
      end;
    until c = #13;
  end;

and you change the Readln(Password); line in ReadLnSecret(Password);
« Last Edit: December 22, 2014, 03:20:20 pm by rvk »

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #80 on: December 22, 2014, 03:33:23 pm »
Oh wow, Thank you very much. Got that working really well. One issue. When I hit back space it displays as a backspace. I could have if #08 then something. I don;t really know.

rvk

  • Hero Member
  • *****
  • Posts: 4329
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #81 on: December 22, 2014, 03:39:18 pm »
Oh wow, Thank you very much. Got that working really well. One issue. When I hit back space it displays as a backspace. I could have if #08 then something. I don;t really know.
Yeah, special characters aren't interpreted here.

If #08 is the only one you need to check for you can do this:
Code: [Select]
  procedure ReadLnSecret(var S: string);
  var
    c: char;
  begin
    s := '';
    repeat
      c := readkey;
      if c = #08 then
      begin
        s := copy(s, 1, length(s) - 1);
        Write(c); // <-- one character back, #08 works as one character to the left in console
        Write(' '); // <-- overwrite the previous *
        Write(c); // <-- and go back one again
      end;
      if not (c in [#13, #08]) then
      begin
        s := s + c;
        Write('*');
      end;
    until c = #13;
  end;

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #82 on: December 22, 2014, 03:43:45 pm »
I have never seen copy(s, 1, length(s) - 1); . Does this copy whats in the string?

rvk

  • Hero Member
  • *****
  • Posts: 4329
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #83 on: December 22, 2014, 05:29:40 pm »
I have never seen copy(s, 1, length(s) - 1); . Does this copy whats in the string?
It copies the string from 1 to length(s) - 1. So essentially it cuts off the last character of the string (which is what you want with a backspace). You could also use System.Delete(S, length(S), 1); but I find the Copy command easier ( and then there is no need to check for S = '' ).

 

TinyPortal © 2005-2018