0

Is there any way to change a uniconnection settings already created in a data-module and connected to a database I just want it to connect to another database :

dmprefrences.AC.disconnect;
dmprefrences.AC.Server := 'localhost' ;
dmprefrences.AC.Port :=  3306 ;
dmprefrences.AC.Username := 'root';
dmprefrences.AC.Password :=  'root';
dmprefrences.AC.Database :=   'Database2';
dmprefrences.AC.Connect;
dmprefrences.AC.open ;
  • You appear to have posted code that answers your question. What more information do you need? – Andy_D Sep 01 '14 at 11:04
  • Obviously you can, otherwise you wouldn't have been able to connect to the original one in the first place. What problem/error message are you getting when you try? – MartynA Sep 01 '14 at 12:21
  • showmessage(booltostr(dmprefrences.AC.connected)); should return 0 for connected, it is returning -1, and everything linked to the database is empty – Jeanette Daher Sep 01 '14 at 12:30
  • You are completely misinterpreting the result of BoolToStr. The code in your comment means that the connected property is True. If you look at the documentation for BoolToStr it states that if the Boolean is true and UseBoolStrs is false (the default) then a Value of True will return '-1'. – Andy_D Sep 01 '14 at 13:28
  • 1
    Also, ShowMessage isn't really how to debug. Use a debugger or OutputDebugString or a logging framework. Please also edit the question to make it clear what you are asking. – David Heffernan Sep 01 '14 at 13:31

1 Answers1

0

Use UniConnectDialog. It's also part of the UniDac.

That way you can connect to any database you like.

Then use the afterconnect property of the UniConnection, something like :

dxStatusBar1.Panels[0].Text := 'Connected';

This works well for SQL server. If you have some other database you can use :

UniConnection1.Database :=UniConnectDialog1.Connection.Database;

user763539
  • 3,509
  • 6
  • 44
  • 103