16 Mar 2009

Connection string for Postgre SQL in C#.NET 2005


Connection string for Postgre SQL in C#.NET 2005 by Npsql

Npgsql

Type: .NET Framework Class Library
Usage: Npgsql.NpgsqlConnection

The Npgsql is based to exist this library (original version) in your project references.
Then define it in your class as next step:

using Npgsql;

How to use that

try
{
NpgsqlConnection NpgCon = new NpgsqlConnection(String.Format("Server={0};Port={1};" +
"User Id={2};Password={3};Database= postgres;",
txtServerName.Text,
txtPort.Text, txtUserID.Text, txtPassword.Text););

NpgCon.Open();
.
.
.
NpgCon.Close();

}
catch (Exception msg)
{
MessageBox.Show(msg.Message);
throw;

}

0 comments: