Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007
    Posts
    13

    Pervasive.SQL and c#

    Hi


    How can i start a conection between c#
    and Pervasive.SQL database ?

    Can you show me how its done, or
    point me to tutrials ?

    Thanks

  2. #2
    Join Date
    Dec 2001
    Posts
    1,075
    As I posted in another forum:
    A few questions and then a sample:

    1. What version of PSQL are you using?
    2. Do you have DDFs for your data?

    The sample below uses ODBC to connect to a PSQL database. There may be other options depending on the version you are using.
    Now the sample:

    Code:
    using System;
    using System.Data;
    using System.Data.Odbc;
    using System.IO;
    
    namespace SimpleADONetTest
    {
    class Class1
    {
    [STAThread]
    static void Main(string[] args)
    {
    try
    {
    OdbcConnection conn=new OdbcConnection("DSN=DEMODATA");
    conn.Open();
    Console.WriteLine("ServerName: " + conn.ServerName.ToString());
    Console.WriteLine("ServerDSN: " + conn.ServerDSN.ToString());
    // Create a SQL command
    string strSQL = "select * from class";
    OdbcCommand DBCmd = new OdbcCommand(strSQL, conn);
    OdbcDataReader myDataReader;
    myDataReader = DBCmd.ExecuteReader();
    Console.WriteLine("FieldCount: " + myDataReader.FieldCount.ToString());
    while (myDataReader.Read())
    {
    for (int i=0;i
    {
    Console.WriteLine("Field " + i.ToString() + ": " + myDataReader[i].ToString());
    }
    }
    myDataReader.Close();
    conn.Close();
    Console.WriteLine("Press Enter to continue");
    Console.ReadLine();
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    Console.ReadLine();
    }
    
    }
    }
    }
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Jul 2007
    Posts
    13
    Thanks for bought of them

    Here is my answer in the second forum

    Thanks for your help.

    1) version 8
    2) yes, i have a database.


    I allready succeded on doing that,
    but i have a problem:

    Im doing it like that, and
    i cant put the information into
    a DataGrid, and i dont know why.


    Code:
    string CoString = @"Provider=PervasiveOLEDB;" + @"Data Source=Z:\server;";
    
    string strSql = "SELECT * FROM TableTest2";
    OleDbConnection con = new OleDbConnection(CoString);
     con.Open();  
    
    OleDbDataAdapter dadapter = new OleDbDataAdapter();
    dadapter.SelectCommand = new OleDbCommand(strSql, con);
    DataSet dset = new DataSet();
    dadapter.Fill(dset, "TableTest2"); 
     con.Close();   
    
     this.dataGridView1.DataSource=dset;

    But, its not putting the data inside
    the dataGrid, why ?

    Thanks.

  4. #4
    Join Date
    Dec 2001
    Posts
    1,075
    See my post in the other forum.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •