Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#dotnet linux中的Postgresql数据库连接代码_C#_.net_Linux_Postgresql_Ubuntu - Fatal编程技术网

c#dotnet linux中的Postgresql数据库连接代码

c#dotnet linux中的Postgresql数据库连接代码,c#,.net,linux,postgresql,ubuntu,C#,.net,Linux,Postgresql,Ubuntu,我对Linux、dotnet和postgres都是新手。我正试图用C#编写一个数据库连接代码。但我犯了个错误 “CS0246无法指定类型或命名空间名称'NpgsqlConnection' 找到(是否缺少using指令或程序集引用?) 我使用的是ubuntu 14.04 64位,dnxcore版本5.0,postgresql,npgsql 3.1.0-alpha6。我在project.jason中将依赖项定义为“Npgsql”:“3.1.0-alpha6”。 我的密码是 using System;

我对Linux、dotnet和postgres都是新手。我正试图用C#编写一个数据库连接代码。但我犯了个错误

“CS0246无法指定类型或命名空间名称'NpgsqlConnection' 找到(是否缺少using指令或程序集引用?)

我使用的是ubuntu 14.04 64位,dnxcore版本5.0,postgresql,npgsql 3.1.0-alpha6。我在project.jason中将依赖项定义为“Npgsql”:“3.1.0-alpha6”。 我的密码是

using System;
using npgsql;
namespace testdbconn
{
  public class tstdb
    {
         NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432;UserId=postgres;Password=mypass;Database=xxxxx;");

         public static void Main()
              {
                    OpenConn();
              }
         public static void OpenConn()
              {
                   try
                   {               
                         conn.Open();
                   }
                  catch (Exception exp)
                   {                
                         MessageBox.Show("Error :S");
                   }
              }
    }
} 
谁能帮帮我,我完全迷路了。提前感谢。

如果您添加了相关的程序集,我认为这是因为您编写名称空间时毫不在意。应该是这样,

using Npgsql;
命名空间名称区分大小写

也不要将
NpgsqlConnection
对象用作应用程序中的字段。在您的方法中定义它们。

如果您添加了相关的程序集,我认为这是因为您编写名称空间时毫不在意它的大小写。应该是这样,

using Npgsql;
命名空间名称区分大小写


也不要将
NpgsqlConnection
对象用作应用程序中的字段。在方法中定义它们。

谢谢,现在我有了新错误,但错误cs0246消失了。谢谢,现在我有了新错误,但错误cs0246消失了。