Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

connect to SQL database

Posted on 2003-03-10
7
Medium Priority
?
160 Views
Last Modified: 2013-11-23
hi
i have a SQL database and i wanna connect to it but i dont know how...
which component i must use ??
plz help me
tanx
0
Comment
Question by:Mahsa60
7 Comments
 
LVL 9

Expert Comment

by:mocarts
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)
mo.
0
 

Expert Comment

by:Imbeginner
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
m.reza


0
 
LVL 6

Expert Comment

by:Stuart_Johnson
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.

Stuart.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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

 

Author Comment

by:Mahsa60
ID: 8101827
i wanna connect my database to a DBGride how i can do it
0
 
LVL 6

Accepted Solution

by:
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.
0
 

Author Comment

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

Author Comment

by:Mahsa60
ID: 8101880
tanx to u all :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

579 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