Lazarus
Programming => Databases => Topic started by: luqas on August 08, 2022, 01:35:20 pm
-
Good morning
I connect to the oracle database I have tables to which we need to add a chekbox column, we do according to the wiki and unfortunately I still have selected
unit Unit1;
{$ mode objfpc} {$ H +}
interface
uses
Classes, SysUtils, oracleconnection, SQLDB, DB, Forms, Controls, Graphics,
Dialogs, DBGrids, StdCtrls, DBCtrls, ValEdit, DBDateTimePicker;
type
{TForm1}
TForm1 = class (TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label1: TLabel;
OracleConnection1: TOracleConnection;
SQLQuery1: TSQLQuery;
SQLTransaction1: TSQLTransaction;
procedure DBGrid1CellClick (Column: TColumn);
procedure DBGrid1UserCheckboxState (sender: TObject; column: TColumn; var AState: TCheckboxState);
procedure FormCreate (Sender: TObject);
procedure FormDestroy (Sender: TObject);
private
public
RecList: TBookmarklist;
end;
var
Form1: TForm1;
implementation
{$ R * .lfm}
{TForm1}
procedure TForm1.DBGrid1CellClick (Column: TColumn);
begin
if Column.Index = 1 then
RecList.CurrentRowSelected: = not RecList.CurrentRowSelected;
end;
procedure TForm1.FormCreate (Sender: TObject);
begin
RecList: = TBookmarkList.Create (DbGrid1);
end;
procedure TForm1.FormDestroy (Sender: TObject);
begin
RecList.Free;
end;
procedure TForm1.DBGrid1UserCheckboxState (sender: TObject; column: TColumn; var AState: TCheckboxState);
begin
if RecList.CurrentRowSelected then
AState: = cbChecked
else
AState: = cbUnchecked;
end;
-
I do not understand what do you want to achieve?
You have in Oracle database table, which has one (or more) boolean columns and you want display values of this column(s) in TDBGrid, where you want place checkbox in these column(s) and this checkbox should be checked when underlaying value is true else unchecked?
-
Hi
You should explain with more details what you expect and the issue...
What is your Oracle version, and what is the type of your "checkbox columns" in the database ?
I do not use Oracle anymore, but your problem could be related with the boolean type in Oracle.
IIRC it was added recently and, depending on the Oracle or Lazarus or Third party version, it was not handled correctly.