Connecting to a Database
Show this topic in Library frames
Once your Pervasive.SQL data provider is installed, you can connect from your application to your database with a connection string. See Connection String Options for the Pervasive.SQL Provider for connection attributes.
The following example illustrates connecting to the database using the Pervasive.SQL data provider from an application developed in Visual Studio.NET, using C#.
- In the Solution Explorer, right-click References.
- Click Add Reference; then, select the Pervasive.SQL data provider in the component list. If the data provider is not in the component list, click Browse and navigate to the data provider assembly.

- Click OK. The Solution Explorer now includes the Pervasive.SQL data provider.

- Add the data provider's namespace to the beginning of your application, as shown in the following C# code fragment:
// Access Pervasive.SQL
using System.Data;
using Pervasive.Data.SqlClient;
- Add the connection information for your server and exception handling code.
try
{
DBConn = new PsqlConnection("ServerDSN=Demo01;
UID=test01;
PWD=test01;
Server=localhost;");
DBConn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
- Close the connection.
// Close the connection
DBConn.Close();