Solved

Best way to access MS SQL server from Delphi

Posted on 2006-10-27
11
454 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:ciuly
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:ciuly
ciuly 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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