C # PostgreSQL operations.

Source: Internet
Author: User
From the Internet, we can see that. NET operates on PostgreSQL. Article
Http://www.zdnet.com.cn/developer/code/story/0,3800066897,39530081-1,00.htm)
According to his example, it is wrong, mainly because of some details, which he did not mention.
You need to add two DLL files: Mono. Security. dll and npgsql. dll.
Here is an example for your reference: 1 Private   Void Button#click ( Object Sender, system. eventargs E)
2 {
3 Richtextbox1.text =   String . Format (
4 " Server = {0}; Port = {1}; userid = {2}; database = testdb; Password = {3}; Protocol = 3; SSL = false; pooling = true; minpoolsize = 1; maxpoolsize = 20; encoding = Unicode; timeout = 60; sslmode = Disable " ,
5 Textbox1.text. Trim (), textbox2.text. Trim (), textbox3.text. Trim (), textbox4.text. Trim ());
6
7 Npgsqlconnection Conn =   New Npgsqlconnection ();
8 Conn. connectionstring = Richtextbox1.text;
9
10 Npgsqlcommand comm =   New Npgsqlcommand ();
11 Comm. Connection = Conn;
12 Conn. open ();
13 Comm. commandtext =   @" Select * From datas; " ;
14 Dataset DS =   New Dataset ();
15 Npgsqldataadapter SDA =   New Npgsqldataadapter ();
16 SDA. selectcommand = Comm;
17 SDA. Fill (DS, " Datas " );
18 If (Ds. Tables [ 0 ]. Rows. Count ! =   0 )
19 {
20 Datagrid1.datasource = DS. Tables [ " Datas " ];
21 MessageBox. Show ( " OK " );
22 }
23 Conn. Close ();
24 }

PostgreSQL driverProgramIs:
Http://pgfoundry.org/frs? Group_id = 1000140

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.