|
Tip>Designer |
|
|
Using ADO directly from GhostFill FillPoints |
|
|
Article #: |
0037 |
|
Contributor: |
Daniel Todes |
|
GF version: |
4.0 |
|
Applies to: |
ADO links to data sources and SQL statements |
|
Last updated: |
March 4, 2002 |
Description
You can use GhostFill script to establish an ADO link to an external data source, and thereafter execute SQL statements directly from a GhostFill FillPoint on the data in the data source.
Explanation
The following example shows how you can establish an ADO connection to a data source and then extract data from the data source using SQL statements in FillPoints:
Use the CreateObject task to establish a connection to a data source, then open the connection:
%[adStateOpen = 1] %[adOpenDynamic = 2] %[adLockOptimistic = 3] %[adCmdText = 1]
%[Connection = CreateObject("ADODB.Connection")]
%[ResultSet = CreateObject("ADODB.Recordset")]
%[Connection.ConnectionString = "Data source = GhostFill ODBC Sample;"]
%[Connection.Open()]
If the connection is successful, the block of SQL statements is executed. The SQL statements iterate through the data source, and for each record set, return the value in the ClientName field:
%[KeepBlockIf(Connection.State = adStateOpen)]
%[SQL = 'Select * from contacts']
%[ResultSet.Open(SQL, Connection, adOpenDynamic, adLockOptimistic, adCmdText)]
%[RepeatBlockWhile(ResultSet.EOF = False)]
%[ResultSet.Fields('ClientName').Value]
%[ResultSet.MoveNext()]
%[EndBlock()]
%[EndBlock()]