Accessing a Pervasive Datasource via ODBC

Valid from List & Label 20
There are several ways to connect to a Pervasive data source and to transfer the data or tables to List & Label.

Option 1: Via combit.ListLabel??.DataProviders.OdbcConnectionDataProvider
Prerequisite: ODBC Pervasive driver installed and Datasource (DSN) set up.
Data: The entire database is fetched.
Restriction: No relations of the data or tables.
Code:
using (ListLabel ll = new ListLabel())
{
    OdbcConnection conn = new OdbcConnection("DSN=PSQLDSN;");
    conn.Open();
 
    OdbcConnectionDataProvider provider = new OdbcConnectionDataProvider(conn, "\"{0}\"");
    ll.DataSource = provider;
 
    ll.Design(LlProject.List | LlProject.FileAlsoNew);
 
    conn.Close();
}


Option 2: Via the ODBC Pervasive Driver (Actian Corporation)
Prerequisite: ODBC Pervasive driver installed and Datasource (DSN) set up.
Data: Own commands (SQL Queries).
Restriction: None known to us.
Code:

using (ListLabel ll = new ListLabel())
{
    OdbcConnection conn = new OdbcConnection("DSN=PSQLDSN;");
    conn.Open();
 
    OdbcCommand cmd = new OdbcCommand("select * from Tabelle1", conn);
    OdbcCommand cmd2 = new OdbcCommand("select * from Tabelle2", conn);
 
    DbCommandSetDataProvider provider = new DbCommandSetDataProvider();
    provider.AddCommand(cmd, "Tabelle1");
    provider.AddCommand(cmd2, "Tabelle2");
 
    //relationen hinzufügen
    provider.AddRelation("Tabelle12Tabelle2", "Tabelle1", "Tabelle2", "ID", "Tabelle1ID");
    ll.DataSource = provider;
 
    ll.Design(LlProject.List | LlProject.FileAlsoNew);
 
    conn.Close();
}


Option 3: Via the Pervasive PSQL ADO.NET Data Provider (Actian Corporation)
Prerequisite: Pervasive.Data.SqlClient Assembly integrated in the project.
Data: Own commands (SQL Queries).
Restriction: None known to us.
Code:

using (ListLabel ll = new ListLabel())
{
    PsqlConnection conn = new PsqlConnection(@"Server Name=myServerAddress;Database Name=myDataBase;User ID=myUsername;Password = myPassword; ");
    PsqlCommand cmd = new PsqlCommand("Select * from Tabelle1");
    PsqlCommand cmd2 = new PsqlCommand("Select * from Tabelle2");
 
    DbCommandSetDataProvider provider = new DbCommandSetDataProvider();
    provider.AddCommand(cmd, "Tabelle1");
    provider.AddCommand(cmd2, "Tabelle2");
     
    //relationen hinzufügen
    provider.AddRelation("Tabelle12Tabelle2", "Tabelle1", "Tabelle2", "ID", "Tabelle1ID");
    ll.DataSource = provider;
 
    ll.Design(LlProject.List | LlProject.FileAlsoNew);
 
    conn.Close();
}









 

IDKBTE001374 KBTE001374