Delphi: MS SQL Server and UniDAC

Delphi: MS SQL Server and UniDAC


This tutorial will take us through using Delphi with MS SQL Server with the UniDAC (Universal Data Access Components) to create a phone logging application.

UniDAC is available from: https://www.devart.com/unidac/download.html

My gear...
My lapel microphone https://amzn.to/3RTEQCo
My boom microphone https://amzn.to/3RVoCZH
My professional microphone https://amzn.to/3QXWKmx
My smartphone https://amzn.to/3BrDZBZ
My webcam https://amzn.to/3QZvxQ6
My DSLR https://amzn.to/3LoXFLg
My video camera (4K) https://amzn.to/3BjQ2Bi
My selfie stick (with Bluetooth remote) https://amzn.to/3BT9ZR4
My headset https://amzn.to/3f1QLQ8
My earbuds (with microphone) https://amzn.to/3Ujpbhn
Closed Caption:

foreign
[Music]
Davis back there with you hey this
morning um
we're gonna do something with the
Microsoft SQL Server
and uh
I'm gonna sport my components called
unidac Universal data access components
you can do the same thing with DB go and
the Ado stuff I just happen to like the
index components
real well
they have more properties that you can
look into and set
things like that so let's go ahead and
get started
gonna
fire up
Microsoft
SQL Server Studio
and uh
actually let's see let's shut this down
and restart it
so you can see the
first the initial dialog screen
hello
there we go it's coming up
it takes a few seconds
that's the latest version as well
see here is the connection to the server
and uh
we want the server name that it's got it
for us
and
we can do SQL Server authentication so
I'll put in the password
and there we go
now as far as the databases go
we're going to use phone log this
morning
I'll expand that
and uh
you can see the
tables here if I can hit that
yeah contacts and log so we'll do a
master detail relationship with these
you can look at the
foreign
design
and here you have it we have a
int type that's a
there is a
identity
specification
and you fixed man that you can see the
is identity yes
I didn't increment one
and then received as one so we start at
one and go on and here's the rest of the
uh
design
and then we can look at uh
DB logs design
it's fairly simple it has an ID also but
it also has this foreign key contact ID
and a date and
note it's a that's a maximum in varchar
so we can uh we can exit that or just
minimize this and we'll start up Delphi
and get it going over here
and what we'll do is create a new
Windows vcl application
there we go
and first thing we want to do
this right let's go to new
other
Delphi database and double click on data
module
and then we'll
expand this out so we can get some room
and then I'm going to scroll down here
to my
unidac or Universal data access
components
they're from
devart.com d-v-a-r-t.com
and we just need to throw a
SQL Server
provider on there
and then
we can close down to five providers and
go to indent I'm going to
connection
and two tables
okay
space these out a little bit
whoa
okay on the connection the first thing
we do is assign the provider name
and that will be
SQL Server
and then the next thing we've got to do
is
build this connection string and so I'm
going to right click on this and I'm
going to use their little wizard for the
connection editor
you see we've got SQL Server
uh
maybe I have to put the port in first
well
oh yeah here it is
um the port is this default of 1433
username essay
password
and then we should be able to find our
database here
yes there it is and we'll do phone log
and connect
and okay
so uh let's give this a better name
we'll call it
on
phone log
and then you'll see when we come over
here to the uh
table
you'll see that it's
the connections taken care of we don't
have to put anything in there we just
have to select a table
and for this one we're going to select
contacts
and then we can right click on this and
go to the fields editor
right click on this
and say add all fields
and we'll come back to that in a minute
and then uh
let's give this a
more understandable name
HBO
contacts
and let's see can we activate it
yes we can okay
and then table two
it's already got the connection name and
we just need to select a table
that'll be log
and we'll name those
TBL oops
okay and then right click on this
because it feels better
right click add all fields and there we
go
now let's go back to unit
one the main form
and we will go to file
use unit
unit three that's the data module
oh come on
there we go
Let's uh give this a little more room to
um
and what we'll do
and I'll spread this up
what we'll do is we'll get everything
but ID because that's maintained by
SQL Server itself we'll get everything
and drag and drop these here
let's get these a reasonable width
there we go
and uh
let's see we'll double click on this
and for the
form creative now we'll say
the uh
contacts
and forget type
and then
uh until three
EPL long
open
and let's see where we're at when we run
this
okay we gotta
need a new folder here
we'll call this
[Music]
um
tutorial
and double click on this
and we'll just save defaults
uh let's see violation
project one
hmm
foreign
[Music]
I don't think form open
is legit here let's copy their cut these
mmm
and
what we'll do give me a minute
we're going to put these on the data
module create event
it will
there we go
now let's see how it goes
yeah I use an access violation means
that that whatever is being called
hasn't been created fully yet
so uh
and let's uh
let's go back to design mode here for a
second
and go to events and we'll get on
Destroy
and we'll paste that again
but we'll change this to
close
same thing here
thank you
now let's go to
main form
and get ourselves and go to the design
and get ourselves
um
Dave control uh give me Navigator
and put that up here
and we'll
tighten this up
oh that was fine
and I'm going to leave space down here
for the master detail the detail table
so
um
let's just say date and notes
we'll come down here
expand this a little bit
they doesn't need to be that big
that's fine
let's find out there and we'll get a DP
navigator for this too
this line please
okay
got that going on
oh and we're gonna go sign
the data source
so this will be
data source two
and this one will be
dead Source One
and we'll tighten this up a little bit
and now let's run and see what we get oh
before we do that
um back to the data module
design mode
and we need to
establish table log As a detail so the
way we do that is go to master source
and let's see we'll say
um
foreign
[Music]
property value okay let's see
um
what we're going to do is on the data
module use unit
one okay
and now let's see uh data source one
and the master fields
will be like this
contact ID
in the
table log
matches the ID
in the table content we'll add that say
okay
we should be good to go let's take a
cursory look at this
okay and you see we've got all our data
and scroll through it
and the related table or the detail
table is keeping up with us
you're gonna put everything
so
let's make this into a usable
application
um
we'll go back here to you know one
and select the form
and we're going to same change caption
where's that
we need to put solution the form to
screen Center
I will
do this here
spring Center
and
let's do State uh
we need
a max length of two
and
character case
of upper
okay
now let's uh we can close these we've
used those enough
um
let's go to Project
oops
project
I didn't mean to do that honest
project options
take a second
appearance
and um I'm gonna go with this wedger
like I'd be liking that recently
got that oh and let's go to uh
options
icons
and we'll load the icon
which we can get
from here
yeah so we'll put a copy
there and save that
um
let me see
uh
you know one
is there anything I'm missing
what's wrong and see what we get
okay
we got
the phone icon phone log msql server
and we got our related tables
and let's have a new one called us uh
all right
see it forces it to application will on
take D and put a
third in there
and we'll say uh
something
eight six
one zero
and an email
MW
at
email
.com this is all fictitious stuff
and before you put a note in you need to
post this
edit
so that it gets its new
ID number
and now we can put in a note zero eight
four yeah
so we can post that
and then
you see uh
where they go there is Martin Way yeah
so uh
there you have it a master detail
relationship in the Microsoft SQL Server
uh we've put it up
and if you built this along with us you
can uh you can use this your phone log I
do
so uh
I like a little icon if you if you
if you don't
know about this let me see if
I can call this up here go to tools
get it package manager
and we'll search for icons
[Music]
wow
foreign
1.0
they have almost 65 000 free icons
each icon is in five flat Styles you see
I've installed that that's where I get
the icons you just search for I just
search for a phone and have a big a huge
amount to choose from and I picked the
one I like the best
so if you install that you can use it
and I use all those icons to dress up
your programs
so there's that
and uh
we'll do this again this just to look
this is all redated table you can tell
by a
this here
this has multiple notes for
for me
not well two notes multiple notes but uh
it doesn't it doesn't mess up the
contact table when you scroll them now
here I don't think
we have multiple modes that's just
single mode I'm the only one that got
the multiple modes
so
and you know when I'm ready I can add
another one
foreign
and we can post that and then you see
there should be three notes now
yeah
three notes
so there you have it uh
the thing I like about the
unidac components is look at this list
of providers that you get
um it covers pretty much every possible
database
I don't have ever heard of redshift but
anyway
they do it and they do db3 and 4 the
best strand four
and maybe even older
ASC I'm not sure what that is
but Advantage database
access you you got pretty much all of
them here
um and DB go doesn't really give all
that so
you can use these
and again that's uh I'll put a link in
the description that's a devart.com
and I think you can get all those
you know that components for I'm
thinking in the ballpark of 145 dollars
and you get a Year's license but you can
use them you know
and infinitum
or you can uh
you can renew your license each year
what have you I think they even have
multiple years up to three years at a
time
so that's a thought
and that's our little application
use it all you like give it to a friend
hello and they'd need SQL Server
we'll do this again with a
free database
but I hope you enjoyed the tutorial I'm
enjoyed doing it for you again I'm
Robert Davis and I hope you have a
wonderful Friday and a great weekend too
and I'll see you in the next tutorial
thanks bye
[Music]

Video Length: 27:50
Uploaded By: Delphi Programming Tutorials
Published: 8/5/2022
View Count: 1,893

Related Software Products
Universal Data Access Components
Universal Data Access Components

Published By:
Devart

Description:
UniDAC: One Set of Delphi Components for Oracle, SQL Server, MySQL, PostgreSQL, SQLite and More Your Delphi application talks to SQL Server today. Tomorrow a customer wants it on PostgreSQL, another runs Oracle, and the new mobile version needs SQLite on the phone. If every database means a different component set, different quirks and a separate copy of your data layer, each new customer turns into a porting project. Universal Data Access Components (UniDAC) from Devart is built for exactly ...


Related Videos
Connect to SQL Server from Windows, MacOS, iOS and Andoid using UniDAC
Connect to SQL Server from Windows, MacOS, iOS and Andoid using UniDAC

Video Length: 02:25
Uploaded By: Devart (2/23/2015)
View Count: 20,072

UniDAC: Native connectivity to various databases and clouds from Delphi
UniDAC: Native connectivity to various databases and clouds from Delphi

Video Length: 06:03
Uploaded By: Devart (1/15/2024)
View Count: 1,765

Delphi : Building a Windows CRUD Console Application with UniDAC + MSSQL
Delphi : Building a Windows CRUD Console Application with UniDAC + MSSQL

Video Length: 07:25
Uploaded By: SAMRID SOMBOON (8/29/2021)
View Count: 1,283

Copyright © 2026, Ivertech. All rights reserved.