Unidac Access Edit Record

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Bob
Posts: 10
Joined: Thu 03 Jan 2008 21:18

Unidac Access Edit Record

Post by Bob » Thu 22 Apr 2010 14:34

I am converting from using the TAdoquery component using a Microsoft Access database to the Tuniquery component.

I am trying to edit a record and it it not working. On the form I have a TAccessUniProvider Component as well. In the below example, unless I specify the SETFIELDSREADONLY=FALSE option - I get a message "Unable to modify a read-only dataset". I have tried the other lines that I commented out with no luck. Now with the code below - it appears that it works, but it doesn't really update the record. The before and after results are the same.

procedure TForm1.Button1Click(Sender: TObject);
var
UniConnection : TUniconnection;
query : TUniquery;
begin
UniConnection := TUniconnection.Create(self);
query := TUniquery.Create(self);
try
UniConnection.ProviderName := 'Access';
UniConnection.Database := 'hedis2010.mdb';
UniConnection.Username := 'Admin';
UniConnection.Password := 'xxxxx';
UniConnection.Connected := True;
if Uniconnection.connected then
begin
query.Connection := UniConnection;
//query.Options.QuoteNames := true;
query.Options.SetFieldsReadOnly := false;
//query.LockMode := lmOptimistic;
//query.LocalUpdate := true;
query.SQL.Text := 'select * from [parameters] where Ucase(description) = UCase(:description)';
query.Params[0].Value := 'INDEXSPACE';
query.Active := true;
try
if not query.eof then
begin
showmessage('Before: ' + query.fieldbyname('data').AsString);
query.Edit;
query.fieldbyname('data').AsString := 'test';
query.Post;
query.Refresh;
showmessage('After: ' + query.fieldbyname('data').AsString);
end;
except on e:exception do
showmessage(e.Message);
end;
end;
finally
query.Free;
UniConnection.Free;
end;
end;

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Mon 26 Apr 2010 09:40

Hello

Please send us the DDL script to create the "parameters" table.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 27 Apr 2010 14:06

Hello

You should replace the query:

select * from [parameters] where Ucase(description) = UCase(:description)

with:

select * from "parameters" where Ucase(description) = UCase(:description)

And your query will be editable.

Post Reply