Topic: How To reverse Value AttachDB Table to Edit.text
How To edit script on Double click at TableGrid1 to display editor3.text, editor4.text, editor5.text
but database from attach database
help me please
Easy For Beginner Student For Me
My Visual Database → Script → How To reverse Value AttachDB Table to Edit.text
How To edit script on Double click at TableGrid1 to display editor3.text, editor4.text, editor5.text
but database from attach database
help me please
Hello Prahousefamily
Why not use a SQL query to retrieve the values of a grid column ?
procedure frmApplication_Button1_OnDoublerClick (Sender: string; var Cancel: boolean);
begin
frmApplication.NameUser.Text := SQLExecute('SELECT clientname FROM application WHERE id='+IntToStr(Form1.TableGrid1.dbItemID));
frmApplication.PhoneUser.Text := SQLExecute('SELECT clientphone FROM application WHERE id='+IntToStr(Form1.TableGrid1.dbItemID));
end;
No matter if the column order of the grid is changed for any reason.
I do this way in my applications and I even add OnKeyUp and OnKeyDown event to navigate the grid and display the different values of a row of the grid.
Is this OK for you ?
JB
Can not use function
procedure frmApplication_Button1_OnDoublerClick (Sender: string; var Cancel: boolean);
begin
frmApplication.NameUser.Text := SQLExecute('SELECT clientname FROM application WHERE id='+IntToStr(Form1.TableGrid1.dbItemID));
frmApplication.PhoneUser.Text := SQLExecute('SELECT clientphone FROM application WHERE id='+IntToStr(Form1.TableGrid1.dbItemID));
end;
i try this SQLExecute not work
because data in table grid from attach database
in project attach database
//public var
var
AppPath: string;
attachdb: string;
procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
????????????????????????????????????????????????????????????????????????????
end;
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
Form1.TableGrid1.dbSQL:=
' SELECT person.firstname,person.lastname, '+
' person.record_count FROM lib.person '+
' WHERE person.firstname like "%'+Form1.Edit1.Text+'%" AND '+
' person.lastname like "%'+Form1.Edit2.Text+'%" ';
Form1.TableGrid1.dbSQLExecute;
end;
begin
AppPath := ExtractFilePath(Application.ExeName);
attachdb:= SQLExecute('ATTACH DATABASE ''lib.db'' as ''lib''');
end
.
how to fix ?
OK Work ! Now Fix Passed Thank You jean.brezhonek
I edit code in even Form1_TableGrid1_OnCellDoubleClick
procedure Form1_TableGrid1_OnCellDoubleClick (Sender: string; ACol, ARow: Integer);
var
libs: TDataSet;
irow :integer ;
begin
irow := Form1.TableGrid1.SelectedRow ;
SQLQuery(
' SELECT person.firstname,person.lastname,'+
' person.record_count FROM lib.person where person.id ='+inttostr(Form1.TableGrid1.dbIndexToID(irow) )
, libs);
while not libs.Eof do
begin
Form1.Edit3.Text := libs.FieldByName('firstname').AsString;
Form1.Edit4.Text := libs.FieldByName('lastname').AsString;
Form1.Edit5.Text := libs.FieldByName('record_count').AsString;
libs.Next;
end;
libs.Free;
end;
and add fileld "ID" in tablegrid1
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
Form1.TableGrid1.dbSQL:=
' SELECT person.firstname,person.lastname, '+
' person.record_count,person.id FROM lib.person '+
' WHERE person.firstname like "%'+Form1.Edit1.Text+'%" AND '+
' person.lastname like "%'+Form1.Edit2.Text+'%" ';
Form1.TableGrid1.dbSQLExecute;
end;
My Visual Database → Script → How To reverse Value AttachDB Table to Edit.text
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi