Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Location
    Sweden
    Posts
    19

    Unanswered: Using Asp.Net + c#.Net to connect to Pervasive v10 by using ODBC

    Hi there,
    am new for using Pervasive v10 and get connection using ODBC to get data from it, i need to use c#.net to get connected to it.

    so i need to know how i can do this in coding side, in C#.net and asp.net, i mean what shall i use in :

    1- Using Directive;

    using ??????????????????????;

    2- i know that i need to use odbcconnection as a conn, but i need to know how, can i read and write to the Pervasive ???


    P.S: i have the connection on my Server Explorer as
    Connection string is DSN=TESTDB
    Provider is .NET Framework Data Provider for ODBC
    State is Open
    Type is Pervasive.SQL
    Version is 10.00.0151 000

    so guys if some can help me i'll be very grateful. thank you

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    You won't see the provider in Server Explorer unless you install the "Design Time" components from the Developer Zone site on Pervasive (http:\\www.pervasive.com/developerzone).

    There are a number of ADO.NET samples on the Pervasive site as well as on the Net.
    Here's a very simple sample that shows how to connect to PSQL:
    Code:
    using System;
    using System.Data;
    using Pervasive.Data.SqlClient;
    using System.IO;
    
    namespace SimpleAdoNetConsole
    {
    	class Class1
    	{
    		[STAThread]
    		static void Main(string[] args)
    		{
    			try
    			{
    				PsqlConnection conn=new PsqlConnection("ServerDSN=demodata;UID=;PWD=;Server=localhost;");
    				conn.Open();
    				Console.WriteLine("ServerName: " + conn.ServerName.ToString());
    				Console.WriteLine("ServerDSN: " + conn.ServerDSN.ToString());
    				// Create a SQL command
    				string SQLstr = "select * from class";
    		
    				PsqlCommand DBCmd = new PsqlCommand(SQLstr, conn);
    				PsqlDataReader myDataReader;
    				myDataReader = DBCmd.ExecuteReader();
    				Console.WriteLine("FieldCount: " + myDataReader.FieldCount.ToString());
    				//Console.WriteLine("Records Affected:" + myDataReader.RecordsAffected.ToString());
    				Console.ReadLine();
    				while (myDataReader.Read())
    				{
    					for (int i=0;i<myDataReader.FieldCount;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
    Feb 2009
    Location
    Sweden
    Posts
    19
    thanks, i'll try to install the component, and let you know ...

    thanks alot

Posting Permissions

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