Using ApolloDataAdapter

<< Click to Display Table of Contents >>

Navigation:  Apollo ADO.NET Provider >

Using ApolloDataAdapter

Namespace: Apollo

Example

Public Sub DoAdapterSelect()

Dim conn As ApolloConnection

Dim cmd As ApolloCommand

Dim adapter As ApolloDataAdapter

 Dim sql As string

 

 conn = New ApolloConnection()

' set to local or to client/server access

 conn.AccessMethod = TAccessMethod.amLocal

 conn.DatabaseName = "C:\Apollo\9.9\x86\Data\"

 

 cmd = New ApolloCommand()

 adapter = New ApolloDataAdapter()

 

 sql = "select * from test"

 adapter.SelectCommand = New ApolloCommand(sql, conn)

 

' create a dataset to hold the data we just got

Dim ds As DataSet = New DataSet()

 

' assign the dataset to the grid

Me.DataGrid1.DataSource = ds

 

' fill the .NET dataset with the data retrieved by the SQL code  adapter.Fill(ds, "test")

 

' close the connection

 conn.Close()

 

End Sub

 

Public Sub DoAdapterInsert()

Dim conn As ApolloConnection

Dim cmd As ApolloCommand

Dim adapter As ApolloDataAdapter

Dim parm As ApolloParameter

Dim sql As string

 

conn = New ApolloConnection()

 

' set local or c/s settings

conn.AccessMethod = TAccessMethod.amLocal

 

cmd = New ApolloCommand()

adapter = New ApolloDataAdapter()

sql = "insert INTO test (First) VALUES ('Mike')"

adapter.InsertCommand = New ApolloCommand()

 

' alternatively, you can set the cmd options as follows:

cmd.Connection = conn

cmd.Connection.Open()

 

cmd.CommandText = sql

cmd.ExecuteNonQuery()

 

conn.Close()

End Sub