Solved

Best way to access MS SQL server from Delphi

Posted on 2006-10-27
11
485 Views
Last Modified: 2013-11-23
Hi,

What is the best (fastest) way to connect to a SQL server database from within Delphi 7 Professional? Any third-party components are welcome too.
And could you please explain how I can do that?

Regards,
Stef
0
Comment
Question by:Delphiwizard
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 17821905
well ... there isn't a fastest way to connect to it. most if not all components/libraries will be equally fast at this operation :)

the issue you could encounter in regards to speed is in how much time you get the data. but this again depends mostly on:
- the sql code you have written
- the network connection
and not on the libraries as well.

this is the general look. if you want ms precizion, then you will probably have to test a few libraries on your environment with the same data/sql queries and of course sql server.

I personally worked with modbc (old version, delphi 3 era). I've heard a few nice things about MySQLDAC but the most used around EE seems to be the zeos components. I never needed mysql from delphi since the D3 era, so I didn't used any delphi mysql libraries since.
0
 

Author Comment

by:Delphiwizard
ID: 17822144
Sorry, but I need to know this for "MS SQL server" not "MySQL".
0
 
LVL 28

Assisted Solution

by:2266180
2266180 earned 200 total points
ID: 17822254
ups. dunno what I was seeing. sorry.
ms sql is strait out of the box. just use ADO. (the general stuff still applies). of course you could use odbc or bde, but I do prefer ADO. bde needs to also ship teh bde engine along with your applicaiton (and a few other downsides, like lot of bugs and all that; of course most of them are probably fixed but at teh time I first started using it, it just made me dislike it so much that I never tried it again) and odbc ... I prefer ADO over it (the only reason for me is because in ADO I don't have to create a dsn :) )
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:Delphiwizard
ID: 17822349
What can you tell me about "Direct Access" Components?
DBxComponents? that are part of the Delphi Enterprise version seem to have this, or has ADO it too?
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17822450
Yes I think that ADO connection objects only come with Delphi Enterprise and higher, not professional.
Do the DBExpress components come with delphi7 professional? or the clientdataset/dataprovider components?
Its been so long since I used any professional version Im a bit out of touch.
Other than that BDE / ODBC using the standard TDataset components I would guess.
0
 
LVL 18

Assisted Solution

by:Johnjces
Johnjces earned 150 total points
ID: 17824424
I concur that ADO is probably the best all around method to access MS SQL.

If you don't have a version of Delphi with ADO components, you can download the following free and they work well.

http://www.alohaoi.com/Software/Products/aoado/ado.htm

http://www.gm-software.de/components.htm 

If you want to try something else, which is an open source project, not ADO... but will allow you to use almost any database server, MS SQL, MySQL, Oracle, to name a fedw, try ZEOS database objects. There has been good activity and updates recently.

Download from:  http://zeos.firmos.at/portal.php

Hope this helps.

JJ
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 17825247
I prefer to use Direct access component, and we use Sdac from crlab, also they have similar components for oracle called odac
http://www.crlab.com/sdac/

there are also free component called anydac, offer direct access to sql server and more RDBMS
http://www.da-soft.com/AnyDACHome.html

and SqlDirect too but not free
http://www.sqldirect-soft.com/

and you can work with sql server directly with Ole Db without the ADO layer, which will be faster
http://www.oledbdirect.com/index.php
0
 
LVL 11

Expert Comment

by:calinutz
ID: 17828798
ADO comes with Professional version too (at least for Delphi 7)
And they are the best way to acces MS SQL Server

Regards
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 17828807
>>And they are the best way to acces MS SQL Server

why you consider it as best way?
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 150 total points
ID: 17832503
Several people have suggested to use ADO and I agree with that. :-)
However, there are several ways that you can work with ADO. There are some Delphi components that wrap around the ADO COM classes in Windows and there are several other third-party ADO components. But you can also just use the raw ADO components, depending on your needs.

Other methods are called "OLE DB" and "DOA" but Microsoft has already made clear that "DAO" won't be supported in 64-bits Windows versions. And OLE DB is just one layer of the whole MDAC design

MDAC = http://en.wikipedia.org/wiki/Microsoft_Data_Access_Components
DAO = Data Access Objects
ADO = ActiveX Data Objects
OLE DB = ?

Problem with SQL Server is that every componentset tends to be a wrapper around some other componentset, adding a bit more functionality, handling a few more situations and whatever more. You would have the fastest access to SQL Server through OLE DB but there are no OLE DB components for Delphi. Even faster would be if you use the TDS protocol directly to communicate with the server. (See http://en.wikipedia.org/wiki/Tabular_Data_Stream for more.) And with SQL Server 2005 you can even use SOAP to communicate with the server.

But in the end, the question won't be which solution is the fastest. I think what's more important is the question which solution is the most reliable. (And still available in the future!) And the answer to that, as provided by everyone else here, is ADO. Just like ciuly said. Good answer, ciuly! ;-)

Btw, whatever you do, don't use the BDE to connect to SQL Server! It's a wrapper around a wrapper and will needlessly increase the size of your project, it will make you dependant on the BDE and worst of all, it's NOT an improvement. The good old days of the BDE are over nowadays. :-(
0
 

Author Comment

by:Delphiwizard
ID: 17876034
Thank you all for the info.
I've decided to go with ADO.

Regards,
Stef
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now