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 > Using Asp.Net + c#.Net to connect to Pervasive v10 by using ODBC

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-09, 05:11
Abrahm75 Abrahm75 is offline
Registered User
 
Join Date: Feb 2009
Location: Sweden
Posts: 19
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
Reply With Quote
  #2 (permalink)  
Old 05-15-09, 10:15
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,015
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.
Reply With Quote
  #3 (permalink)  
Old 05-15-09, 11:20
Abrahm75 Abrahm75 is offline
Registered User
 
Join Date: Feb 2009
Location: Sweden
Posts: 19
thanks, i'll try to install the component, and let you know ...

thanks alot
Reply With Quote
Reply

Thread Tools
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