T := TSQLTransaction.Create(DM);
DB := TSQLConnector.Create(DM);
Q := TSQLQuery.Create(DM);
DBC := DM.phSpeedProject.GetDBConnection(ConnectionId);
if DBC <> nil then begin
DB.ConnectorType := DBC.DBType;
DB.DatabaseName := DBC.DBDatabase;
DB.Password := DBC.DBPwd;
DB.UserName := DBC.DBUid;
DB.Hostname := DBC.DBHost;
if DBC.DBPort <> '' then
DB.HostName := DB.HostName+':'+DBC.DBPort;
// DB.DBFile := DBC.DBFile;
end;
DB.Transaction := T;
try
DB.Open;
Q.DataBase := DB;
if pos('MYSQL', uppercase(DBC.DBType)) > 0 then begin
Q.SQL.Text := 'show tables';
Q.Open;
while not Q.EOF do begin
sl.Add(Q.Fields[0].AsString);
Q.Next;
end;
end;
except
// SB.SimpleText := 'connection FAILED';
end;
Q.Free;
DB.Free;
T.Free;
....
DB.Transaction := T;
try
DB.Open;
DB.GetTableNames(sl, true);
...
but generates an error : the metadata is not available for this type of database
What did you put in ConnectorType for the TSQLConnector??Code: [Select]DB := TSQLConnector.Create(DM);
Ah, I need to be able to use different databases like in Zeos, but wanted to stay with standard lazarus functionality. I think that I have some other issue, because if I use the mysqlib.dll from my current database (setup by wamp) I doesn't work because the lib cannot be loaded. I'll do some more tests. I'm currently using an old dll that does work. That might be the issue.Make sure your bitness of Lazarus and dll match.
Well... actually the problem is something else: I use a SQL connector. If you use the gettablenames of that component you get the 'the metadata is not avaliable for this type of database'. If you use the 'bare' database components it works well. I'll try to dive deeper...
@rvk: no it doesn't create that. But the odd thing is that you will need the appropiate db component on the form to get access to it's prototype. Otherwise the connector doesn't work.It does. It create a "Proxy"-connection internally (you can see that in the source). FProxy in TSQLConnector is filled with the correct TMySQLXXConnection. It is used in TSQLConnector for lots of things.
I thought the TSQLConnection automatically created a TMySQL50Connection according to the ConnectorType but apparently it doesn't work like that.