Hi,
I used the code below and it works fine
cn.Driver:='Microsoft Access Driver (*.mdb, *.accdb)';
cn.Params.Add('DBQ='+ExtractFilePath(Application.ExeName) + 'yourdb.accdb');
cn.Connected:=True;
cn.KeepConnection:=True;
SQLQuery1.SQL.Text:='SELECT * FROM table1';
SQLQuery1.Open;
Sorry for my stepping in but I've encountered the same issue.
Are you all talking about the dsn-less connection via ODBC with Access database (*.mdb)?With the above connection code,it still failed to connect to an access database if dsn is not defined in ODBC source panel a 'database =' property is not provided in IDE.
All I want is just to connect an access database (*.mdb) with sqlDB component(TODBCconnection,QSqlTransaction,TSqlQuery...),the most important point is there is NO need to set up a dsn in the ODBC Source panel!Something like in C# below code is sufficient to connect to an access *.mdb database:
OleDbConnection nwindConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;")
Solution would be appreciated.
Regards,
Sam