You are not logged in.
Pages: 1
Hi, I'm having trouble connecting to MySQL through either ODBC or OLE. I've installed the 64 bit drivers for both, and did the ODBC and OLE 'Test Connection' Successfully.
I've compiled SynDBEdit 64 bit and also tried my source code below. I think I'm just entering a wrong field somewhere, but don't know where. Examples on this board seem ancient because they generate compiler errors, so I think the syntax may have changed in the last year.
var
MySQL: TOLEDBODBCSQLConnectionProperties;
Conn: TSQLDBConnection;
Query: TSQLDBStatement;
F: TFileStream;
password: RawUTF8;
begin
// Model := CreateSampleModels;
write('PASSWORD: ');
readln(password);
// MySQL := TOLEDBODBCSQLConnectionProperties.Create('mysql.1', 'localhost',
// 'cecs', 'root', StrToUTF8(password));
MySQL := TOLEDBODBCSQLConnectionProperties.Create('MSDASQL.1','localhost', 'cecs', 'root', StrToUTF8(password));
try
Conn := MySQL.NewConnection;
try
Query := Conn.NewStatement;
try
Query.Execute('select * from employer', True, []);
// select * from cecs.employer
// It FAILS at Query above with error: Unspecified Error [Microsoft][ODBC Driver Manager] Data Source Name not found and no specififed default driver
F := TFileStream.Create('result.json', fmCreate);
try
Query.FetchAllToJSON(F, True);
finally
F.Free;
end;
finally
Query.Free;
end;
finally
Conn.Free;
end;
finally
MySQL.Free;
end;
Database.Free;
Model.Free;
I've tried changing the first argument of ..connectionproperties to 'MySQL ODBC 3.5 Unicode Driver' and other things, but the error never budges.
I've tried creating named user DSNs, named System DSNs, no change.
I've hacked at this for hours, so I'm asking for help.
Any hints on how to get a wor
Last edited by erick (2015-09-21 15:50:41)
Offline
A collegue of mine figured it out for me, so I'm documenting for those who follow me.
You enter:
pseudoname := 'mysql.3';
MySQL := TOLEDBODBCSQLConnectionProperties.Create( pseudoname, pseudoname, '', 'UseridBlah', 'passwordDooHicky');
Then, as long as you have no mismatch between the driver bitness (32 versus 64), it works.
Thanks
Offline
Pages: 1