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
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
A basic windows program s...
by
Leledumbo
[
Today
at 05:08:41 pm]
Troubles with function de...
by
Remy Lebeau
[
Today
at 05:04:39 pm]
SFTP Connection
by
Remy Lebeau
[
Today
at 04:53:00 pm]
Ghostscript-API-Wrapper
by
DiduTech
[
Today
at 04:46:15 pm]
Looking for better way...
by
Khrys
[
Today
at 04:26:35 pm]
Random Carpet Designs: La...
by
majolika
[
Today
at 04:03:11 pm]
how to use SetSysColors?
by
TRon
[
Today
at 03:54:53 pm]
fpspreadsheet (Spready) -...
by
wp
[
Today
at 03:53:51 pm]
Forum slow?
by
marcov
[
Today
at 03:42:03 pm]
Add Artificial Intelligen...
by
VisualLab
[
Today
at 03:23:30 pm]
Deal or no Deal graphic
by
TBMan
[
Today
at 02:57:28 pm]
Pac man and Missile Comma...
by
TBMan
[
Today
at 02:51:05 pm]
Bug and crash. I think th...
by
VisualLab
[
Today
at 02:51:00 pm]
Tesseract for ocr
by
rvk
[
Today
at 02:30:29 pm]
New Package to use WIA sc...
by
MaxM74
[
Today
at 01:25:49 pm]
read text file position b...
by
Packs
[
Today
at 01:09:39 pm]
Context Sensitive Help fo...
by
marcov
[
Today
at 12:36:26 pm]
[Solved]Generic methods i...
by
cdbc
[
Today
at 11:47:01 am]
SplitString issue
by
Thaddy
[
Today
at 11:20:17 am]
changing the position of ...
by
kjteng
[
Today
at 10:48:10 am]
Usage of Lazlogger 2 - st...
by
PeterX
[
Today
at 10:08:04 am]
Generic function is 'wrea...
by
cdbc
[
Today
at 09:54:06 am]
Image processing
by
MarkMLl
[
Today
at 09:10:54 am]
show popupmenu in listvie...
by
ASerge
[
Today
at 06:19:40 am]
Accessing parent form fro...
by
nikel
[
Today
at 03:26:35 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to make a table (Read 3735 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: 5387
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