Difference between revisions of "TSQLQuery"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "'''TSQLQuery''' is a fundamental database query component for use with any supported database. The component is found on SQLdb tab of the Component Palette. ==See als...")
 
m (Fixed syntax highlighting)
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''TSQLQuery''' is a fundamental database query component for use with any supported database. The component is found on [[SQLdb tab]] of the [[Component Palette]].
+
{{TSQLQuery}}
 +
{{Infobox databases}}
 +
 
 +
'''TSQLQuery''' [[image:tsqlquery.png]] is a fundamental database query component for use with any supported database. The component is found on [[SQLdb tab]] of the [[Component Palette]].
 +
 
 +
Typical use of a TSQLQuery:
 +
  SQLTransaction1.Database := SQLConnection1;
 +
  SQLQuery1.Transaction := SQLTransaction1;
 +
  DataSource1.DataSet := '''SQLQuery1''';
 +
  DBGrid1.DataSource := DataSource1;
 +
 
 +
===Select===
 +
 
 +
Select all columns from table somelist:
 +
 
 +
<syntaxhighlight lang=pascal>
 +
SQLQuery1.SQL.Text := 'SELECT * FROM somelist';
 +
SQLQuery1.Open();
 +
</syntaxhighlight>
 +
 
 +
===Insert===
 +
 
 +
Insert a new record into table somelist:
 +
 
 +
<syntaxhighlight lang=pascal>
 +
SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)';
 +
SQLQuery1.ExecSQL();
 +
SQLTransaction1.Commit();
 +
</syntaxhighlight>
  
 
==See also==
 
==See also==
* [[Working With TSQLQuery]]
+
 
 +
* [http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html TSQLQuery doc]
 +
* [http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html Using SQLdb]
  
 
{{LCL Components}}
 
{{LCL Components}}

Revision as of 01:36, 2 March 2020

English (en) français (fr) 日本語 (ja) русский (ru)

Databases portal

References:

Tutorials/practical articles:

Databases

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

TSQLQuery tsqlquery.png is a fundamental database query component for use with any supported database. The component is found on SQLdb tab of the Component Palette.

Typical use of a TSQLQuery:

 SQLTransaction1.Database := SQLConnection1;
 SQLQuery1.Transaction := SQLTransaction1;
 DataSource1.DataSet := SQLQuery1;
 DBGrid1.DataSource := DataSource1;

Select

Select all columns from table somelist:

 SQLQuery1.SQL.Text := 'SELECT * FROM somelist';
 SQLQuery1.Open();

Insert

Insert a new record into table somelist:

 SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)';
 SQLQuery1.ExecSQL();
 SQLTransaction1.Commit();

See also


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu