Hi,
Many years ago I wrote a program that reads in an Access database and presented the user with some simple search options, it was written in Visual basic and the code is lost. More recently I have tried to use Lazarus and I have struggled but in the last week or two I have made some progress.
The principle is that it will read the database structure, present the records in a stringgrid, allow searches depending on the field type etc. Nothing too difficult.
However, whilst I can get that all working fairly well, I cannot seem to be able to update a record. The way I wanted to do it was present eh record in a stringgrid, allow the fields to be edited, and then replace the whole record with the contents of the stringgrid.
Here's what I tried:-
//make ODBC connection
ODBCConnection1.Driver:= 'Microsoft Access Driver (*.mdb, *.accdb)';
ODBCConnection1.Params.Add('DBQ=.\id931.mdb'); // or specify full path to mdb file
ODBCConnection1.Params.Add('Locale Identifier=1031');
ODBCConnection1.Params.Add('ExtendedAnsiSQL=1');
ODBCConnection1.Params.Add('CHARSET=ansi');
ODBCConnection1.Connected:= True;
ODBCConnection1.KeepConnection:= True;
//transaction
SQLTransaction1.DataBase:= ODBCConnection1;
SQLTransaction1.Action:= caCommit;
SQLTransaction1.Active:= True; //not applied to ms access(false)
SQLQuery0.DataBase:= ODBCConnection1;
SQLQuery0.UsePrimaryKeyAsKey:= False;
DataSource0.DataSet:= SQLQuery0;
SQLQuery0.Update.Text:=<a large string>
SQLQuery0.Open;
SQLQuery0.ApplyUpdates
And then I get errors relating to databse not open or Operation cannot be performed on an inactive dataset.
Ive tried a few things like SQLQuery0.ExecSQL an others and no joy.
I would welcome any help on this as the project is nearly finished and this is the last thing to fix.
Thanks in advance.