We help IT Professionals succeed at work.

Best way to access MS SQL server from Delphi

Stef Merlijn
Stef Merlijn asked
on
Medium Priority
2,425 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
Comment
Watch Question

Top Expert 2007

Commented:
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.
Stef MerlijnDeveloper

Author

Commented:
Sorry, but I need to know this for "MS SQL server" not "MySQL".
Top Expert 2007
Commented:
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 :) )

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Stef MerlijnDeveloper

Author

Commented:
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?
Mike LittlewoodEngineer

Commented:
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.
Commented:
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
Mohammed NasmanSoftware Developer
CERTIFIED EXPERT

Commented:
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

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

Regards
Mohammed NasmanSoftware Developer
CERTIFIED EXPERT

Commented:
>>And they are the best way to acces MS SQL Server

why you consider it as best way?
Self-employed developer
CERTIFIED EXPERT
Commented:
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. :-(
Stef MerlijnDeveloper

Author

Commented:
Thank you all for the info.
I've decided to go with ADO.

Regards,
Stef
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.