UniDAC + DBGrid + PickList With Access Violation error

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Wilson Alex
Posts: 16
Joined: Fri 13 Dec 2019 16:39

UniDAC + DBGrid + PickList With Access Violation error

Post by Wilson Alex » Fri 05 Mar 2021 12:28

When I used UniDAC 8.3.2 in delphi 7 as the connection tool between DBGrid and SQLite database, there was a problem that puzzled me: I can't use the PickList function of DBGrid.

This is my data table field: ID, Name, Job.

There are four components on my form: TUniConnection, TUniQuery, TUniDataSource, TDBGrid.

This is the relationship between them:
TUniQuery.Connection := TUniConnection;
TUniDataSource.DataSet := TUniQuery;
TDBGrid.DataSource := TUniDataSource;

The Job field of the database is bound to the second column of the DBGrid, and I set the PickList of this column. After the program runs, the DBGrid can load the data normally, but when I use the drop-down list of the second column, the mouse selects a new value Then select this column of other rows, the program will report an error: Access violation at address 0058A552 in module'Project1.exe'. Read of address 0AD06FF8.

I tried to replace DBGrid with NextDBGrid and received the same error. After I updated UniDAC to 8.4.1, I also cannot use the PickList function, but the AV error will not pop up and the program will stop responding.

I am not sure where the problem is, can you give me some suggestions?

Wilson Alex
Posts: 16
Joined: Fri 13 Dec 2019 16:39

Re: UniDAC + DBGrid + PickList With Access Violation error

Post by Wilson Alex » Fri 05 Mar 2021 12:55

This is my test code:

-- Table structure for Test
DROP TABLE IF EXISTS "Test";
CREATE TABLE "Test" (
"ID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"Name" TEXT,
"Job" TEXT
);

-- Records of Test
INSERT INTO "Test" VALUES (1, 'Evita', NULL);
INSERT INTO "Test" VALUES (2, 'Brion', NULL);
INSERT INTO "Test" VALUES (3, 'Haze', NULL);

This is the value of PickList: Programmer, teacher, driver.

This is the code of the form:

object Form1: TForm1
Left = 192
Top = 130
Width = 450
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 8
Top = 64
Width = 417
Height = 265
DataSource = UniDataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'Name'
Visible = True
end
item
Expanded = False
FieldName = 'Job'
PickList.Strings = (
'Programmer'
'teacher'
'driver')
Visible = True
end>
end
object UniConnection1: TUniConnection
DataTypeMap = <
item
DBType = 603
FieldType = ftString
end>
ProviderName = 'SQLite'
Database = 'mdasdb.db'
SpecificOptions.Strings = (
'SQLite.BusyTimeout=5000'
'SQLite.ClientLibrary=sqlite3.dll')
PoolingOptions.ConnectionLifetime = 10000
Pooling = True
Connected = True
LoginPrompt = False
Left = 24
Top = 16
end
object UniQuery1: TUniQuery
Connection = UniConnection1
SQL.Strings = (
'SELECT * FROM Test')
Left = 64
Top = 16
end
object UniDataSource1: TUniDataSource
DataSet = UniQuery1
Left = 112
Top = 16
end
end

----------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBAccess, Uni, MemDS, UniProvider,
SQLiteUniProvider;

type
TForm1 = class(TForm)
UniConnection1: TUniConnection;
UniQuery1: TUniQuery;
UniDataSource1: TUniDataSource;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
UniQuery1.Active := True;
end;

end.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC + DBGrid + PickList With Access Violation error

Post by MaximG » Thu 11 Mar 2021 15:15

We'll look into your sample project and get back to you in 1-2 days.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC + DBGrid + PickList With Access Violation error

Post by MaximG » Fri 12 Mar 2021 13:51

We haven't been able to reproduce the issue with application freezing in UniDAC 8.4.1. Please try to explicitly close a connection to the database before exiting the application and let us know if this helps:

Code: Select all

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  UniConnection1.Close;
end;

Wilson Alex
Posts: 16
Joined: Fri 13 Dec 2019 16:39

Re: UniDAC + DBGrid + PickList With Access Violation error

Post by Wilson Alex » Fri 19 Mar 2021 06:21

Hi MaximG, I am not sure if this is a bug. In my test, this problem is not only caused by UniDAC 8.3.2, but also in previous versions. When I set the CachedUpdates property of UniQuery to True, and the UniQuery.CommitUpdates method was executed when the form was destroyed, the problem did not reappear for the time being. I guess it may be memory corruption when updating the DataSet in real time. Enabling cache update can alleviate this problem, but it still exists. If necessary, I can send you the test code.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC + DBGrid + PickList With Access Violation error

Post by MaximG » Wed 24 Mar 2021 09:42

Please create and send us a sample project with source code where the issue can be reproduced. For your convenience, please use the e-support form https://www.devart.com/company/contactform.html

Post Reply