Saturday, January 10, 2009

How to connect Delphi to database SQL Server

Delphi provides several ways to connect to the database SQL Server. One of the connections is using ADODB. The component to create this connection is ADOConnection


How to setting this component? You can try this simple program below:

1. Open your Delphi Program ( in this example I am using Delphi 6)
2. Design the form like the picture below:



Design each object property with following data:
TEdit :
Edit1
  • Name : Eservername
  • Text: <blank>
Edit2
  • Name: Euser
  • Text: <blank>
Edit3
  • Name: Epassword
  • Text: <blank>
  • PasswordChar:*
Edit4
  • Name: Edbname
  • Text: <blank>

TButton:
  • Name: Button1
  • Caption : Test Connection
TADOConnection
  • LoginPrompt: False

3. Double Click Button1 and Type source code below:



4. Running the program by pressing F9

5. Click Test Connection Button, you will have prompt message whether the connection Success or fail , see the picture below



Have a nice Try :)

Related Topics:
How to connect Delphi to database SQL Server
Select Distinct, Not In and Right Outer Join in SQL Command
Function Date and Time in Foxpro

No comments:

Post a Comment