Problem about connect Postgre using ADO.NET

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem about connect Postgre using ADO.NET

NGUYEN TRONG LANH

Hello pgsql support team!

At first, forgive me if the content of the email is not your responsibility. I have problem when I try connect Postgre using ADO.NET, I not see PostgreSQL in Data Source list.

I have done to install Npgsql package, install Npgsql PostgreSQL extension but the problem is not solve.

Please let's me know if you have any ideas to solve this.

Thanks!


-- 
-------------------------------------------------------------------++
                                         
               |    |    |               BRYCEN VIETNAM Co.,Ltd.
              )_)  )_)  )_)              NGUYEN TRONG LANH
             )___))___))___)|            Development Department
            )____)____)_____)||          25 Nguyen Van Cu,Hue,Vietnam
          _____|____|____|____|||__      Email: [hidden email]
---------|                   /---------  Tel: +84-(0)234-6558332
   ^^^^^ ^^^^^^^^^^^^^^^^^^^^^           Mobile:+84-(0)93 8924 386
     ^^^^      ^^^^     ^^^    ^^        Website:http://www.brycen.com.vn
          ^^^^      ^^^                  
--------------------------------------------------------------------++
Reply | Threaded
Open this post in threaded view
|

Re: Problem about connect Postgre using ADO.NET

Charles Clavadetscher
Hello

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of NGUYEN TRONG LANH
> Sent: Dienstag, 23. Mai 2017 09:18
> To: [hidden email]
> Subject: [DOCS] Problem about connect Postgre using ADO.NET
>
> Hello pgsql support team!
>
> At first, forgive me if the content of the email is not your responsibility. I have problem when I try connect
> Postgre using ADO.NET, I not see PostgreSQL in Data Source list.
>
> I have done to install Npgsql package, install Npgsql PostgreSQL extension but the problem is not solve.
>
> Please let's me know if you have any ideas to solve this.

If I understand it correctly you installed Npgsql that is a driver for PostgreSQL using ADO.NET.
What is still missing is a data source, i.e. a DSN where you choose the driver and enter connection and login information.

How you create a DSN depends on the version of Windows you are on.

Hope this helps.
Regards
Charles

> Thanks!
>
>
>
> --
> -------------------------------------------------------------------++
>
>                |    |    |               BRYCEN VIETNAM Co.,Ltd.
>               )_)  )_)  )_)              NGUYEN TRONG LANH
>              )___))___))___)|            Development Department
>             )____)____)_____)||          25 Nguyen Van Cu,Hue,Vietnam
>           _____|____|____|____|||__      Email: [hidden email] <mailto:[hidden email]>
> ---------|                   /---------  Tel: +84-(0)234-6558332
>    ^^^^^ ^^^^^^^^^^^^^^^^^^^^^           Mobile:+84-(0)93 8924 386
>      ^^^^      ^^^^     ^^^    ^^        Website:http://www.brycen.com.vn
>           ^^^^      ^^^
> --------------------------------------------------------------------++



--
Sent via pgsql-docs mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
Reply | Threaded
Open this post in threaded view
|

Re: Problem about connect Postgre using ADO.NET

Neil Anderson-2
In reply to this post by NGUYEN TRONG LANH
On 2017-05-23 3:17 AM, NGUYEN TRONG LANH wrote:
> Hello pgsql support team!
>
> At first, forgive me if the content of the email is not your
> responsibility. I have problem when I try connect Postgre using ADO.NET,
> I not see PostgreSQL in Data Source list.
>
> I have done to install Npgsql package, install Npgsql PostgreSQL
> extension but the problem is not solve.

Hi, I use Npgsql in my project. I'm not sure what you mean by 'I do not
see PostgreSQL in Data Source list', Npgsql does not discover the server
for you, you must provide it with a connection string, create a
connection and execute commands. Here is a code example:

var connString =
"Host=localhost;Username=postgres;Password=passwrd;Database=postgres";

using (var conn = new NpgsqlConnection(connString))
{
     conn.Open();

     // Insert some data
     using (var cmd = new NpgsqlCommand())
     {
         cmd.Connection = conn;
         cmd.CommandText = "INSERT INTO data (some_field) VALUES (@p)";
         cmd.Parameters.AddWithValue("p", "Hello world");
         cmd.ExecuteNonQuery();
     }

     // Retrieve all rows
     using (var cmd = new NpgsqlCommand("SELECT some_field FROM data",
conn))
     using (var reader = cmd.ExecuteReader())
         while (reader.Read())
             Console.WriteLine(reader.GetString(0));
}

For future reference Npgsql have wonderful documentation here
http://www.npgsql.org/index.html, and they prefer questions be posted to
Stack Overflow.

--
Neil Anderson
[hidden email]
http://blog.postgrescompare.com


--
Sent via pgsql-docs mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs