var MyForm : TclForm; vScroll:TCLVertScrollBox; sLabel : TclLabel; void SqLiteInsertData; { try Clomosy.DBSQLiteQuery.Sql.Text = ' INSERT INTO depo ( name,kod) VALUES (''saç'',''001''); INSERT INTO depo (name,kod) VALUES (''saç2'',''002'') '; Clomosy.DBSQLiteQuery.OpenOrExecute; ShowMessage('Adding data to the table was successful!'); except ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage); } } void SqLiteConnectionCreateTable; var TableExists: Boolean; { try Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBDepo.db3', ''); // Check if the table exists Clomosy.DBSQLiteQuery.Sql.Text = 'SELECT name FROM sqlite_master WHERE type="table" AND name="depo";'; Clomosy.DBSQLiteQuery.OpenOrExecute; // Check the results TableExists = not Clomosy.DBSQLiteQuery.Eof; // Create the table if it does not exist if not (TableExists) { Clomosy.DBSQLiteQuery.Sql.Text = 'CREATE TABLE depo( name TEXT NOT NULL, kod TEXT NOT NULL )'; Clomosy.DBSQLiteQuery.OpenOrExecute; ShowMessage('Table successfully added to the database!'); SqLiteInsertData; } else { ShowMessage('The Products table already exists.'); }
except ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage); } } void GetData; var Qry : TClSQLiteQuery; i : Integer; { try Qry = Clomosy.DBSQLiteQueryWith('SELECT * from depo'); Qry.OpenOrExecute; if (Qry.Found) { for i = 0 to Qry.RecordCount-1 { sLabel = MyForm.AddNewLabel(vScroll,'sLabel'+IntToStr(i),''); sLabel.StyledSettings = ssFamily; sLabel.TextSettings.Font.Size=20; sLabel.Align = alTop; sLabel.Margins.Left= 5; sLabel.Margins.Top= 5; sLabel.Height = 50; sLabel.Text = Qry.FieldByName('name').AsString +'-'+ Qry.FieldByName('kod').AsString ; sLabel.AutoSize = True; sLabel.WordWrap = True; Qry.Next; } } except ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage); } }
{ MyForm = TclForm.Create(Self); vScroll = MyForm.AddNewVertScrollBox(MyForm,'vScrollBox'); vScroll.Align = alMostTop; vScroll.Height = MyForm.clheight-70; SqLiteConnectionCreateTable; GetData; MyForm.Run; } ilk eklediğim veriyi labela yazıyor ama diğer verileri yazmıyor.
|