If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > Pervasive.SQL and c#

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Dec 2001
Posts: 1,069
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.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Jul 2007
Posts: 13
Thanks for bought of them

Here is my answer in the second forum

Quote:
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.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Dec 2001
Posts: 1,069
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On