connect to SQL database

Posted on 2003-03-10
Medium Priority
Last Modified: 2013-11-23
i have a SQL database and i wanna connect to it but i dont know how...
which component i must use ??
plz help me
Question by:Mahsa60
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8101687
which version of Delphi you have?
what type of SQL database?

there is different choices to connect to database - BDE, ADO, dbExpress (and more, but these are most used)

Expert Comment

ID: 8101733
hi mahsa,
Sql database !?
The various way existed to use of sql statements in delphi.

But I prefer ADO for this issue.
please do these works:

1-     Add adoconnection to your form
2-     Click on connectionstring  , select your database( select build, if your db is access select   MICROSOFT JET 4,and the location stc )
3-     Add ADOQUERY to your form,
4-     Select adoconnection1 for adoQUERY1.connection
5-     Write your sql statement at sql of adoquery1
6-     Activate your ADOQUERY1

piroz basheed


Expert Comment

ID: 8101786
If you're using Microsoft SQL Server, use the same method as Imbeginner said, but with a slight difference:

  Start Delphi.  
  Create new project.  
  Go to the ADO Tab and drop a TADOConnection on the form.  
  In the Object Inspector, click on the Connection String ellipsis (...).  
  Click on the Build button
  Select Microsoft OLE DB Provider for SQL Server.  
  Click the Next button.  
  Select your MS SQL Server from the drop down list.
  Define your method of authentication (be it windows or SQL).  
  Enter a username/password if required.  
  Select the database you wish to use.  
  Click the Test Conenction button to validate you have everything setup correctly.  
  Click OK.

To do basic table access, drop a TADOTable component onto the form and link it's Connection property to the TADOConnection you just created.  You should be able to select a table from the TableName property (after logging in that is).

The same method applies when doing query based acces - drop a TADOQuery on the form, link it's Connection property and enter your desired SQL in the SQL Property.

Hope this helps.


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 8101827
i wanna connect my database to a DBGride how i can do it

Accepted Solution

Stuart_Johnson earned 200 total points
ID: 8101846
Drop a TADOComponent on the form, follow instructions above.

Drop a TADOTable table on the from, follow instructions above.

Drop a TDataSource on the from.  Set it's DataSet property to the ADOTable component.

Drop a TDBGrid on the from.  Set it's DataSource property to the DataSource component.

If you Open (or Active = true) the ADOTable, you'll see the DBGrid fill up.

Author Comment

ID: 8101853
ok i connect to my SQL database , now how can i display my data in my database on my form ???

Author Comment

ID: 8101880
tanx to u all :)

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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