PostgreSQL is a very advanced object-relational database management system (ordbms). Currently, it has the most powerful features and the most advanced free software database system. Some features are not even available in commercial databases. This database research program originated from Berkeley (BSD) has now been developed into an international development project and has a wide range of users. Since the acquisition of MySQL by Sun, I believe many friends who are uneasy about the acquisition will turn to the future of PostgreSQL. I have previously mentioned in my blog how to install and install PostgreSQL through the source code in Ubuntu. PostgreSQL database is used as the backend data storage in ASP. NET. There are two Connection Methods:
I. using commercial components using postgresqldirect. net
Currently, commercial components use postgresqldirect. net, but the cost is required. The cheapest Standard Edition online price is also 1000 yuan.
Postgresqldirect. Net is a data generator control that provides direct PostgreSQL database connection for Microsoft. NET Framework. It is completely based on the ADO. Net method, so you can use it using the method provided by the standard ADO. NET data.
After installation, the postgresqldirect component contains pgsqlconnection pgsqlcommand pgsqldataadapter and other controls (such as) on the Visual Studio 2005 toolbar, and then adds reference to the project: CoreLab. data and CoreLab. postgreSQL allows you to drag and drop controls to connect to the database. The usage of 2005 is basically the same as that of the built-in control. You can also writeCodeThe code for connecting to the database is as follows:
Pgsqldataset DS = new pgsqldataset ();
String SQL = "select * from test where tid = 3000 ";
Pgsqlconnection con = new pgsqlconnectio ("User ID = username; Password = PWD; host = hostname; database = test ");
Pgsqldataadapter da = new pgsqldataadapter (SQL, con );
Da. Fill (DS );
This. Maid = Ds;
This. datagridview1.datamember = Ds. Tables [0]. tostring ();
Toolbar after postgresqldirect. NET is installed
Ii. Use the open-source component npgsql
Npgsql is a database function that provides data driver services for open-source PostgreSQL on the. NET Framework Platform.ProgramSet (. NET data provider), which allows users to establish applications used to access the PostgreSQL database on the. NET Framework Platform.
Decompress the package and copy the two DLL files to the bin directory of the application. Add mono. Security and npgsql to the project and add using npgsql to the Code. The Code is as follows:
String SQL = "select * from test where tid = 3000 ";
Npgsqlconnection con = new npgsqlconnection ("Server = hostname; uid = username; Pwd = PWD; database = test ");
Npgsqldataadapter da = new npgsqldataadapter (SQL, con );
Dataset DS = new dataset ();
Da. Fill (DS );
This. Maid = Ds;
This. datagridview1.datamember = Ds. Tables [0]. tostring ();
Related links:
Postgresqldirect. Net official website
Npgsql Official Website
Official PostgreSQL website
Http://pgfoundry.org/frs? Group_id = 1000140