Using SQL

<< Click to Display Table of Contents >>

Navigation:  Apollo OLEDB > Using Apollo OLEDB >

Using SQL

The method and syntax for using Apollo SQL with Apollo OLEDB in local and client/server mode with the Apollo Database Server, is the same. The ConnectionString needs to be modified to select which mode your application works in.

Connecting to Local Tables

Dim conn As New ADODB.Connection

Dim recs As New ADODB.Recordset

Dim sql As String

Dim prov_local As String

 

prov_local = "Provider=ApolloOLEDB9.ApolloOLEDB9;" & _

"Data Source = c:\Apollo\9.9\Data\; " & _

"FetchCount=50;" & _

"AccessMethod=amLocal;" & _

"SetTables=MailTo.dbf, MailTo, ttSXFOX, '', FALSE, '' | " & _

 Security.dbf, Security, ttSXFOX, '', FALSE, '';"

 

conn.Open prov_local

sql = "SELECT * FROM Security"

' adCmdText is used for SQL access

' adCmdTableDirect is used for direct table access

recs.Open prov_local, conn, adOpenDynamic, adLockOptimistic, adCmdText

Set DataGrid1.DataSource = recs

 

Connecting to Apollo Database Server (Client/Server)

The Apollo Database Server must be running at the machine address specified by the Host property in order for the following snippet of code to work.

Dim conn As New ADODB.Connection

Dim recs As New ADODB.Recordset

Dim sql As String

Dim prov_server As String

 

prov_server = "Provider=ApolloOLEDB9.ApolloOLEDB9;" & _

"Data Source = SAMPLEDATA; " & _ ' Alias defined in the Apollo Server

"TableType=ttSXFOX; " & _

"ConnectionUser=SYSDBA; " & _

"ConnectionPassword=masterkey; " & _

"ConnectionHost=127.0.0.1;" & _

"ConnectionPort=8121;" & _

"FetchCount=50;" & _

"CommitLevel=clNormal;" & _

"AccessMethod=amServer;" & _

"SetTables=MailTo.dbf, MailTo, ttSXFOX, '', FALSE, '' | " & _

Security.dbf, Security, ttSXFOX, '', FALSE, '';"

 

conn.Open prov_server

sql = "SELECT * FROM Security"

recs.Open prov_server, conn, adOpenDynamic, adLockOptimistic, adCmdText

Set DataGrid1.DataSource = recs