<< Click to Display Table of Contents >> Navigation: ADONetVCL > Getting Started > First Steps to use ADONetVCL |
This article guides you through the creation of your first application built using the Delphi edition of ADONetVCL.
Introduction
This tutorial has three main sections:
▪Establishing the connection to the database: how to use Delphi to create an application that will connect to a database.
▪Selecting rows from the database: hook the data up to a grid and display it at design time.
Establishing the Connection to the Database
In this article, we use the Microsoft SQL Server's Northwind demo database and a predefined connectionstring. Let's start by creating a new "VCL Forms Application Delphi for Win32".
First, drop a TSqlClientConnection component onto the form selected from the "ADO.Net SQL Server" page of the Delphi Tool Palette. This component is responsible to establish and control the database connection.
Next, defined the connection string attributes from the Params property.
After setting the Connected property to True, ADONetVCL will display a Login Dialog:
Here you can enter your user credentials. Press the OK button to establish the connection to the DB. After the connection is successfully established, the Connected property will still be set to True, otherwise it will be reset to False and ADONetVCL will display an appropriate error message.
Selecting Rows from the Database
Now drop a TSqlClientQuery component from the "ADO.Net SQL Server" palette page onto the form. This component is responsible for the execution of SQL commands, fetching rows from the DB and for posting changed data back to the DB.
Set its Connection property to SqlClientConnection1 to hook the query to a database connection.
Click on its SQL property and enter the following SQL command into the editor window:
SELECT * FROM Orders
Press the OK button to close the editor. This stores the SQL command text into the TSqlClientQuery component's SQL property.
Next, drop a standard Delphi TDataSource component from the "Data Access" palette page onto your form. Set its DataSet property to SqlClientQuery1. Now drop a TDBGrid control onto the form from the "Data Controls" page and set its DataSource property to DataSource1.
Finally, set SqlClientQuery1's Active property to True. This will send the SQL command to the DBMS, which will execute the command and return a result set. This data will be displayed by the DBGrid1 control:
Summary
This article has provided a tutorial showing how to create a simple client-server application using ADONetVCL for Delphi. It shows how to use the ADONetVCL connection and query components to establish a connection to the DB and return rows to the client without actually writing any code.
For other DBMS Getting Started demo applications see ...\Demos\Samples\Getting Started folder.