Using lazrus 2.2 ORC1-fpc-3.2.2-win64 error message: Project MyAccessPractice raised exception class EODBCException with message 'Could not connect with connection string'DRIVER=[Microsoft Access Driver(*.mdb,*.accdb)]; DBQ=C:\Lazarus_MSAccess\MyAccess.accdb;' ODBC error details: LastReturnCode:SQL-ERROR;Record1:SqlState:IM4002;NativeError 0; Message:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified;
Here is the code, copied from internet unit AccessUnit; {$mode objfpc}{$H+} interface uses Classes, SysUtils, odbcconn, SQLDB, DB, Forms, Controls, Graphics, Dialogs, DBGrids, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; DataSource1: TDataSource; DBGrid1: TDBGrid; Label1: TLabel; ODBCConnection1: TODBCConnection; SQLQuery1: TSQLQuery; SQLTransaction1: TSQLTransaction; procedure Button1Click(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin ODBCConnection1.Driver:='Microsoft Access Driver (*.mdb,*.accdb)'; ODBCCOnnection1.params.add('DBQ='+ExtractFilePath(Application.ExeName)+'MyAccess.accdb'); ODBCConnection1.Connected:=TRUE; ODBCConnection1.KeepConnection:=TRUE; SqlTransaction1.DataBase:=OdbcConnection1; SqlQuery1.DataBase:=ODBCConnection1; SQLQuery1.UsePrimaryKeyAsKey:=False; SqlQuery1.SQL.Text:='Select * FROM Student'; Datasource1.DataSet:=Sqlquery1; DBGrid1.DataSource:=DataSource1; If ODBCConnection1.Connected then begin label1.Caption:='Connected'; end; SqlQuery1.Open; end; end. Current MS Access Driver Microsoft Access Driver (*.mdb,*,accdb) Version 16:00 15928020006
-- _______________________________________________ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus