Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
How to make a table
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
The Future of FPC
by
440bx
[
Today
at 04:29:34 pm]
; after then
by
Hansvb
[
Today
at 04:25:48 pm]
ThorVG - test (lightweigh...
by
LeP
[
Today
at 03:07:25 pm]
AdvancedHTTPServer: A Go-...
by
LeP
[
Today
at 03:01:15 pm]
Frustrating Error When us...
by
TYDQ
[
Today
at 01:43:32 pm]
Questions from a Windows ...
by
anse
[
Today
at 01:18:40 pm]
We are starting to use La...
by
ALLIGATOR
[
Today
at 12:50:41 pm]
Status of FPC 3.4.0 or FP...
by
gidesa
[
Today
at 12:35:41 pm]
Notetask 1.1.1 - Free cro...
by
AlexanderT
[
Today
at 12:00:08 pm]
Fast Canvas Library V1.05...
by
backprop
[
Today
at 11:36:25 am]
How to determine the unkn...
by
CM630
[
Today
at 11:22:22 am]
Lazarus/FreePascal Bug
by
cdbc
[
Today
at 10:52:58 am]
how to enable multihelper...
by
dsiders
[
Today
at 03:35:27 am]
Bee Hive solitaire
by
TBMan
[
Today
at 03:22:09 am]
AI Created Music
by
Tony Stone
[
Today
at 03:02:08 am]
Send form to true left an...
by
mas steindorff
[
Today
at 02:39:34 am]
Help needed compiling
by
jamie
[
Today
at 02:33:02 am]
Free Pascal for a small e...
by
dbannon
[
Today
at 02:24:49 am]
Debian removes FPC/Lazaru...
by
dbannon
[
Today
at 02:09:35 am]
makefiles
by
PascalDragon
[February 12, 2026, 11:37:48 pm]
[ANN] fpGUI Toolkit v2.0....
by
Fred vS
[February 12, 2026, 10:45:14 pm]
TRichMemo EM_FORMATRANGE ...
by
AgriMensor
[February 12, 2026, 08:50:07 pm]
fpGUI Toolkit v2.0.1 has ...
by
Roland57
[February 12, 2026, 08:22:06 pm]
[SOLVED] Defining TDBDrop...
by
1HuntnMan
[February 12, 2026, 08:08:22 pm]
Problems in drawing an ar...
by
simsee
[February 12, 2026, 07:52:25 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to make a table (Read 4296 times)
Thomas Colvin
New Member
Posts: 11
How to make a table
«
on:
September 17, 2017, 04:29:37 pm »
In Borland Delphi 3 have Database Wizard and can make tables.
How do I make a table in Lazarus?
Thanks, Thomas
Logged
Handoko
Hero Member
Posts: 5515
My goal: build my own game engine using Lazarus
Re: How to make a table
«
Reply #1 on:
September 17, 2017, 04:58:46 pm »
You can search the web for free database tools. For dbf database, you can try CDBF Explorer 0.60 or MyDbf Studio 0.4 Beta. Both are free, I use them.
http://www.softpedia.com/get/Internet/Servers/Database-Utils/CDBF-Explorer.shtml
http://mydbfstudio.altervista.org/
I prefer to generate the table files manually if my program can't find them when starting. Here is my code for generating dbf tables:
Code: Pascal
[Select]
[+]
[-]
procedure
DataFilePrepare
;
var
NewFieldDefs
:
TDbfFieldDefs
;
NewFieldDef
:
TDbfFieldDef
;
isRestructureNeeded
:
Boolean
;
Z
:
Integer
;
begin
with
frmMain
.
Database
,
NewFieldDef
do
begin
// Create table and first field if the table isn't existed
if
(
not
(
FileExists
(
FilePathFull
+
DirectorySeparator
+
TableName
)
)
)
then
begin
FieldDefs
.
Add
(
'GROUPID'
,
ftInteger
,
0
,
True
)
;
CreateTable
;
end
;
// Create all remain fields if they're not existed
Open
;
isRestructureNeeded
:
=
False
;
NewFieldDefs
:
=
TDbfFieldDefs
.
Create
(
frmMain
)
;
NewFieldDefs
.
Assign
(
DbfFieldDefs
)
;
Z
:
=
FieldIndex
(
'SORTID'
)
;
if
(
Z <
0
)
then
begin
NewFieldDef
:
=
NewFieldDefs
.
AddFieldDef
;
FieldName
:
=
'SORTID'
;
FieldType
:
=
ftInteger
;
Required
:
=
True
;
isRestructureNeeded
:
=
True
;
end
;
Z
:
=
FieldIndex
(
'DATE'
)
;
if
(
Z <
0
)
then
begin
NewFieldDef
:
=
NewFieldDefs
.
AddFieldDef
;
FieldName
:
=
'DATE'
;
FieldType
:
=
ftDate
;
Required
:
=
False
;
isRestructureNeeded
:
=
True
;
end
;
Z
:
=
FieldIndex
(
'TEXT'
)
;
if
(
Z <
0
)
then
begin
NewFieldDef
:
=
NewFieldDefs
.
AddFieldDef
;
FieldName
:
=
'TEXT'
;
FieldType
:
=
ftString
;
Size
:
=
60
;
Required
:
=
False
;
isRestructureNeeded
:
=
True
;
end
;
Z
:
=
FieldIndex
(
'MEMO'
)
;
if
(
Z <
0
)
then
begin
NewFieldDef
:
=
NewFieldDefs
.
AddFieldDef
;
FieldName
:
=
'MEMO'
;
FieldType
:
=
ftMemo
;
Required
:
=
False
;
isRestructureNeeded
:
=
True
;
end
;
Close
;
// Restructure the table if new field is added
if
(
isRestructureNeeded
)
then
begin
RestructureTable
(
NewFieldDefs
,
True
)
;
DeleteFile
(
(
FilePathFull
+
DirectorySeparator
+
DataFileName
+
'_bck.dbf'
)
)
;
end
;
NewFieldDefs
.
Free
;
end
;
end
;
«
Last Edit: September 17, 2017, 05:00:29 pm by Handoko
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
How to make a table
TinyPortal
© 2005-2018