i want to change MyConnection1.Password but ...

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
iqprog

i want to change MyConnection1.Password but ...

Post by iqprog » Mon 29 Nov 2004 22:31

Hi,

MyConnection1.Password := 'mypassword';
MyConnection1.Connected := True;
MyConnection1.Password := ''; // <== MyConnection1 automatic disconnected.

i want to change MyConnection1.Password but I don't want to
MyConnection1 disconnected;

sorry my english little.

thanks.

best regards.

optima
Posts: 1
Joined: Tue 30 Nov 2004 08:28

Post by optima » Tue 30 Nov 2004 08:36

What exactly do you want to do?

If you want the user password to be changed on the MySQL server, use a TMyCommand component linked to your connection and execute the following SQL:
MyCommand.SQL.Text :=
'SET PASSWORD = PASSWORD('''+NewPassword+''')';
MyCommand.Execute;

I hope this helps.

iqprog

thanks but this is not my problem and solution

Post by iqprog » Tue 30 Nov 2004 09:31

i am not want to user password.

i want to Password property of MyConnection Component.
but when i changed password property, if MyConnection.Connected then MyConnection auto disconnected but i don't want disconnected.

sorry little english.

thanks

best regards.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: i want to change MyConnection1.Password but ...

Post by Ikar » Tue 30 Nov 2004 09:33

Changing MyConnection.Password property has no sense for the established connection.

iqprog

please try example, Ikar

Post by iqprog » Tue 30 Nov 2004 14:36

thanks Ikar
but....
try please example.

procedure TForm1.Button1Click(Sender: TObject);
begin
MyConnection1.Password := 'mypass';
MyConnection1.Connected := True;
// ok no problem

if MyConnection1.Connected then
showmessage('connection ok.') // ok no problem
else
showmessage('not connection');

MyConnection1.Password := '';

if MyConnection1.Connected then
showmessage('connection ok.')
else
showmessage('not connection'); // PROBLEM
end;

i want to change password and i want to not disconnect.

i want to security.
this solution for security.

because hack programs viewing component properties.

thanks.

best regards.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: please try example, Ikar

Post by Ikar » Thu 02 Dec 2004 07:39

To store a password in source code is unsafe, regardless where you put it - .dfm or .pas files. The best choice for security reasons is probably to ask user for password.

What does not suit you in behavior where a connection is reestablished?

iqprog

Post by iqprog » Fri 03 Dec 2004 16:37

dear IKAR,

i do not store the password in .dfm or .pas

my problem is after the connection, i want to make this: MyConnection1.Password:=''

but when use this MyConnection1.Password:='' , MyConnection1 disconnect automatically.

after i get the password from user and establish the connection, i want to clean the value of object password property.

example in my last reply was sent explain to my problem. if you run that codes you can understand what i try to say.

Thanks,

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 06 Dec 2004 15:48

In our opinion, clearing of the password after establishing a connection has no sense. If malicious program can get access to address space of the application, it doesn't make sense how much time the password is available.

Post Reply