Page 1 of 1

i want to change MyConnection1.Password but ...

Posted: Mon 29 Nov 2004 22:31
by iqprog
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.

Posted: Tue 30 Nov 2004 08:36
by optima
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.

thanks but this is not my problem and solution

Posted: Tue 30 Nov 2004 09:31
by iqprog
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.

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

Posted: Tue 30 Nov 2004 09:33
by Ikar
Changing MyConnection.Password property has no sense for the established connection.

please try example, Ikar

Posted: Tue 30 Nov 2004 14:36
by iqprog
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.

Re: please try example, Ikar

Posted: Thu 02 Dec 2004 07:39
by Ikar
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?

Posted: Fri 03 Dec 2004 16:37
by iqprog
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,

Posted: Mon 06 Dec 2004 15:48
by Ikar
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.