-
Content Count
300 -
Joined
-
Last visited
-
Days Won
1
Serge_G last won the day on November 13 2021
Serge_G had the most liked content!
Community Reputation
83 ExcellentAbout Serge_G
- Birthday 06/29/1956
Technical Information
-
Delphi-Version
Delphi 11 Alexandria
Recent Profile Visitors
1776 profile views
-
so, use this one not only dat2.sqlite. you can also use '..\..\Data\dat2.sqlite' (second ..\ go up one level win32 first ..\ to project) if you want to use only dat2.sqlite database have to be in this directory
-
Are you sure of that? Program in debug mode is in a xxx\win32\debug directory where xxx is where are your project, unit and dfm path
-
You can add parameters , just adding an array FDQuery1.Open('SELECT * FROM DAT2 WHERE <Column>=:V',[<aValue>]); easy, and quick, no need to close FDQuery1
-
'D:\Database=Delphi 11 Community\My Projects\FDTest\Data\dat2.sqlite' Problem is here. I don't think path is correct. First this = is somehow perturbing me, and those white spaces 🙄 don't help I suspect you use part of the info here but, don't use 'Database' just the database file path Then I am not sure your database is disconnected when you run program (set option ActiveStoredUsage to [] or only [auDesignTime] as @haentschman simplify your code, code can be only FDquery1.Open(query); or FDquery1.Open('Select * from DAT2'); And last but not least, you will be confronted with a "locking" problem if you don't set connexion option LockingMode to Normal
-
Did you consider using regular expressions ? uses system.regularexpressions; procedure TForm1.Button1Click(Sender: TObject); var reg : TRegEx; r : String; const s = 'This is (string) which need to (remove)'; begin reg:=TRegEx.Create('\([^()]*\)'); r:=reg.Replace(s,''); showmessage(r); end;
-
Hum, looking at your dfm, I saw you use DBX components (hate those 😄). I was wondering why till I click on the link ! My suggestion still the same, use Firedac components 😉 As samples, you can find some clues in C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\Database\FireDAC\Samples\Getting Started\SQLite and more Let me show you my version of your objective unit1.dfm and .pas object Form1: TForm1 Left = 0 Top = 0 Width = 686 Height = 501 AutoScroll = True Caption = 'SQlite test' Color = clAqua Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Segoe UI' Font.Style = [] OnCreate = FormCreate TextHeight = 15 object DBGrid1: TDBGrid Left = 0 Top = 0 Width = 672 Height = 177 Align = alTop DataSource = DataSource1 TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -12 TitleFont.Name = 'Segoe UI' TitleFont.Style = [] end object DBNavigator1: TDBNavigator Left = 0 Top = 177 Width = 672 Height = 25 DataSource = DataSource1 Align = alTop TabOrder = 1 ExplicitTop = 183 end object Button1: TButton Left = 120 Top = 208 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 2 OnClick = Button1Click end object Memo1: TMemo Left = 0 Top = 237 Width = 672 Height = 229 Align = alBottom Lines.Strings = ( 'This will be fed via Button1 click') ScrollBars = ssVertical TabOrder = 3 end object FDConnection1: TFDConnection Params.Strings = ( 'Database=C:\Users\Public\Documents\Embarcadero\Studio\22.0\Sampl' + 'es\Data\fddemo.sdb' 'LockingMode=Normal' 'DriverID=SQLite') ConnectedStoredUsage = [] Connected = True LoginPrompt = False Left = 288 Top = 16 end object FDTable1: TFDTable IndexFieldNames = 'CategoryID' Connection = FDConnection1 ResourceOptions.AssignedValues = [rvEscapeExpand] TableName = 'Categories' Left = 176 Top = 32 end object DataSource1: TDataSource DataSet = FDTable1 Left = 376 Top = 48 end end unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids, Vcl.StdCtrls, Data.DB, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.Phys.SQLiteWrapper.Stat, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Comp.Client ; type TForm1 = class(TForm) FDConnection1: TFDConnection; DBGrid1: TDBGrid; DBNavigator1: TDBNavigator; Button1: TButton; Memo1: TMemo; FDTable1: TFDTable; DataSource1: TDataSource; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; implementation {$R *.dfm} uses StrUtils; procedure TForm1.Button1Click(Sender: TObject); var I: Integer; S : String; begin fdtable1.First; memo1.Lines.Clear; while not Fdtable1.EOF do begin memo1.Lines.Add('knowing fieldnames and type'); memo1.Lines.Add(Format('%s %s %s',[fdtable1.FieldByName('CategoryID').asString, fdtable1.FieldByName('CategoryName').asString, fdtable1.FieldByName('Description').asString])); memo1.Lines.Add('using fielddefs'); S:=''; for I := 0 to FdTable1.FieldDefs.Count - 1 do begin if FDtable1.Fields[i].DataType=ftBlob // not readable data then S:=S+' (GRAPHIC)' else S:=S+Ifthen(I>0,' ','')+ // no separator for for first field FDtable1.Fields[i].asString; end; Memo1.Lines.Add(S); fdtable1.Next; end; fdtable1.First; end; procedure TForm1.FormCreate(Sender: TObject); begin fdtable1.Open(); end; end. Note. Table used contains only a few records so it is acceptable to use this sort of code, with huge one a thread should be considered, but, for a beginner it's a big piece
-
TFDBatchMove with non NULL column in target table
Serge_G replied to TurboMagic's topic in Databases
One other way is to use a Query as datasource, then you can rename columns or set columns and so on i.e SELECT ...., KASE_EINSTELLUNGEN as DRAWBACK_CALCULATION, 0 AS PRINT_SMALLBONS .... FROM You said you use onNewRecord but, did you try onBeforePost ? (I don't check if this event is called) -
Think this page is for Delphi Community version
-
Agree @Stano Firebird SQL is a very good RDBMS, all my pro GPAO suite use it. SQLite has also some advantages for mono-station programs ZeosLib can be used with many database system, not only firebird ones You have only to change Zconnection.protocol parameter to sqlite (or sqlite-3). If you find more doc ZEOSDBO+Firebird you can apply all (or at least a good part of) the doc to SQlite as well. Effectively when I wrote (never finished, but on the web) a (French) tutorial about ZEOS components my samples was Firebid ones also
-
I need help writing a component that works with livebinding.
Serge_G replied to kabiri's topic in Cross-platform
Ah, the "synch" one ! I never search for this one. In my mind you need at least to declare in your code procedure ObserverToggle(const AObserver: IObserver; const Value: Boolean); protected function CanObserve(const ID: Integer): Boolean; override; Then check a unit like FMX.Listview.pas (searching 'observer') EditLinkID, PositionLinkID and IteratorLinkID (from System.Classes) seems to be the keys -
I need help writing a component that works with livebinding.
Serge_G replied to kabiri's topic in Cross-platform
have a look at http://docwiki.embarcadero.com/RADStudio/Seattle/en/Tutorial:_Creating_LiveBindings-Enabled_Components in short, you need to declare these procedures and function in your component code procedure ObserverToggle(const AObserver: IObserver; const Value: Boolean); protected function CanObserve(const ID: Integer): Boolean; override; procedure ObserverAdded(const ID: Integer; const Observer: IObserver); override; and do some register observable members If you read French, I wrote some tutorials (part I, part II) -
Got same issue. As workaround, I force UseCustomGlyphs to true at runtime. procedure TForm1.FormCreate(Sender: TObject); begin for var ctrl in GetControls() do begin if ctrl is TRzCheckBox then TRZCheckBox(ctrl).UseCustomGlyphs:=true; end; end;
-
Can I make two suggestions? First one, if you absolutely want to keep Delphi 7 use, try to install ZEOSLIB (aka ZEOSDBO) and use this data access component suite instead of DBExpress Second, try Delphi 11 community, with his Firedac components,
-
Same thing for me ! I tried your sample, giving me a 326 value for a GMT one Then I wrote this simple code procedure TForm1.FDQuery1MONCREATION_DATEGetText(Sender: TField; var Text: string; DisplayText: Boolean); begin text:=sender.asString; end; Giving me an "Incorrect argument for time encoding. " error with my french version
-
@Dmitry Arefiev My tests was with Delphi 12 first. Some links or clues ? Agree, even if I rarely use FDTable 😉