Search found 5 matches

by vetalkw
Tue 07 Jun 2022 09:11
Forum: SQLite Data Access Components
Topic: UniTable1.Delete;
Replies: 1
Views: 8521

Re: UniTable1.Delete;

decision:

Code: Select all

procedure TFormP1.StringGrid2CellDblClick(const Column: TColumn;
  const Row: Integer);
begin
    UniTable2.RecNo:=ns+1;//in another part of the code, I assign NC the line number that the user clicked on
    UniTable2.Edit;
    ShowMessage('record '+UniTable2.Fields[2].AsString+' deleted');
    UniTable2.Delete;
end;
you also need to make sure that your table has at least one column with the status "primary key".
by vetalkw
Sat 04 Jun 2022 17:26
Forum: SQLite Data Access Components
Topic: UniTable1.Delete;
Replies: 1
Views: 8521

UniTable1.Delete;

Good afternoon!
there is a code:

Code: Select all

procedure TFormP1.StringGrid2CellDblClick(const Column: TColumn;
  const Row: Integer);
begin
    UniTable2.RecNo:=1;
    UniTable2.Delete;
    ShowMessage('record '+IntToStr(UniTable2.RecNo)+' deleted');

end;
all rows in the table are deleted from me, how do I delete only record № 1?it seemed to me that if I put the carriage on the the first line (UniTable 2.RecNo:=1;) then the current row will be deleted, but now all rows are being deleted from my table.
how do I delete only line №1?
by vetalkw
Fri 16 Apr 2021 19:16
Forum: SQLite Data Access Components
Topic: ugly code
Replies: 3
Views: 33697

Re: ugly code

this is what you need!
now please help me with placing my Edits in VertScrollBox2
two questions:
1) how do I make all created Edits visible? (now Visible:=true only for the Edit that is currently being processed in the loop (the other Edits are invisible).
2) how to say that each next Edit should be 10 points lower than the previous one?
the code I use:

Code: Select all

procedure TForm7.TabItem2Click(Sender: TObject);
var
  i, ic, ib: Integer;
const
  NamePrefix = 'MyEdit';
begin
  UniTable1.RecNo:=1+Combobox1.ItemIndex;
  UniTable2.Active:=true;
  ShowMessage ('Unitable2.FieldCount-4='+inttostr(Unitable2.FieldCount-4));
  for i := 1 to Unitable2.FieldCount-4 do begin
    TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
    with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
    begin
      ShowMessage(inttostr(i));
      Parent := VertScrollBox2;
      text:=inttostr(i);
      Left:=10;
      Top:= i * 20;
    end;
  end;
end;
I tried to replace the line:

Code: Select all

      Left:=10;
      Top:= i * 20;
replacement option number 1:

Code: Select all

      TEdit.Create(Self).Margins.Left:=10;
      TEdit.Create(Self).Margins.Top:= i * 20;
replacement option number 2:

Code: Select all

      TEdit(FindComponent(NamePrefix + IntToStr(i))).Margins.Left:=10;
      TEdit(FindComponent(NamePrefix + IntToStr(i))).Margins.Top:= i * 20;
replacement option number 3:

Code: Select all

      TEdit(NamePrefix + IntToStr(i)).Margins.Left:=10;
      TEdit(NamePrefix + IntToStr(i)).Margins.Top:= i * 20;
by vetalkw
Thu 15 Apr 2021 10:30
Forum: SQLite Data Access Components
Topic: ugly code
Replies: 3
Views: 33697

ugly code

hello
now I have this code, which I do not like:

Code: Select all

procedure TForm7.Button1Click(Sender: TObject);
  var
    ic:integer;
begin
  i:=Unitable2.FieldCount;
  UniTable2.Append;
  UniTable2.Fields[1].AsString:=Edit2.Text;
  UniTable2.Fields[2].AsString:=Edit3.Text;
  UniTable2.Fields[3].AsString:=Edit4.Text;
  UniTable2.Fields[4].AsString:=Edit5.Text;
  UniTable2.Fields[5].AsString:=Edit6.Text;
  UniTable2.Fields[6].AsString:=Edit7.Text;
  UniTable2.Fields[7].AsString:=Edit8.Text;
  UniTable2.Fields[8].AsString:=Edit9.Text;
  UniTable2.Fields[9].AsString:=Edit10.Text;
  UniTable2.Fields[10].AsString:=Edit11.Text;
  UniTable2.Fields[11].AsString:=Edit12.Text;
  UniTable2.Fields[12].AsString:=Edit13.Text;
  UniTable2.Fields[13].AsString:=Edit14.Text;
  UniTable2.Fields[14].AsString:=Edit15.Text;
  UniTable2.Fields[15].AsString:=Edit16.Text;
  UniTable2.Fields[16].AsString:=Edit17.Text;
  UniTable2.Fields[17].AsString:=Edit18.Text;
  UniTable2.Fields[18].AsString:=Edit19.Text;
  UniTable2.Fields[19].AsString:=Edit20.Text;
  UniTable2.Fields[20].AsString:=Edit21.Text;
  UniTable2.Fields[21].AsString:=Edit22.Text;
  UniTable2.Post;
end;
how do I implement this code in a loop, so that there are fewer lines of code and the code is more beautiful?

instead of: UniTable2.Fields[21].asString I can specify UniTable2.Fields[ic]asString
but I do not know how to specify Edit[ic+1]. Text instead of Edit22.Text?
by vetalkw
Fri 19 Mar 2021 10:12
Forum: SQLite Data Access Components
Topic: UniConnection
Replies: 1
Views: 15953

UniConnection

Hello!
I want to connect UNIDAC to my database (RCEM1).
unfortunately UniDAC does not connect my database (RCEM1).
I have read these instructions:
https://www.devart.com/unidac/docs/data ... htm#sqlite
https://www.devart.com/unidac/docs/using-sqlite.htm
https://www.devart.com/unidac/docs/usin ... connection
https://www.devart.com/unidac/docs/basics.htm
.....
apparently I make a mistake somewhere, and I can't identify the error (maybe I overheated).
Figure 1: Error while connecting UniConnection1 to the RCEM database.
Image


Figure 2: location of the database file (it is located in the same folder as my project)
Image


In Figure3: I open the RCEM1 database in DB Browser (SQLite) (to show that the database is working).
Image


please tell me where I made a mistake.
P.S.: I tried to load other SQLite database files, there is also an error.