Database name / no name

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
[email protected]
Posts: 17
Joined: Sat 02 May 2009 11:20

Database name / no name

Post by [email protected] » Mon 14 Sep 2009 12:35

I am trying to use UniDac to access either Advantage or MySql depending on a parameter setting in my app. I am having a problem accessing table data due to the fact the MySql requires the database name. ie..

MySql: Select * from mydb.Customer
ADS: Select * from Customer

Has anyone come across / resolved this problem? :?:

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 Sep 2009 09:20

There are two ways to resolve the problem:
1) Set the Database property of TUniConnection to 'mydb'. Then execute MySQL query without the database name.
2) Use {if} operator of Unified SQL:

Code: Select all

SELECT * FROM {if MySQL}mydb.{endif}Customer

[email protected]
Posts: 17
Joined: Sat 02 May 2009 11:20

Post by [email protected] » Wed 16 Sep 2009 19:05

Hi Plash. My preffered method is #1 as I will not know the database name at runtime (my program switches databases dynamically). However, the Database property of the UniConnection seems to hold the full path to the database file / location. Am I missing something? Can this field be used as an 'Alias'? :o

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 17 Sep 2009 07:47

In MySQL database name is just a name. When you use MySQL provider you can change the Database property without disconnecting from the server.

Post Reply