2014-02-07 64 views
3

我的数据库脚本如下。npgsql引发的错误异常消息

CREATE TABLE books 
(
    book_name national character varying(50) not null primary key 
); 

,当我尝试以下的C#代码

private void button1_Click(object sender, EventArgs e) 
{ 

    string sql = "INSERT INTO books(book_name) SELECT NULL;"; 
    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; 
    using (NpgsqlConnection connection = new NpgsqlConnection(connectionString)) 
    { 
     connection.Open(); 
     using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(sql, connection)) 
     { 
      npgsqlCommand.ExecuteNonQuery(); 
     } 
    } 

} 

它给了我这种类型的错误:

An unhandled exception of type 'System.NotSupportedException' occurred in Npgsql.dll

Additional information: Backend sent unrecognized response type: _

我知道我传递NULLNOT NULL柱。我想获得确切的错误信息。上述错误意味着什么?

+1

你只是偶然使用PostgreSQL 9.3?众所周知的是(在邮件列表中)除了最新版本的Npgsql之外,其他所有版本的PostgreSQL都会抛出一些错误的异常并表现出奇怪的行为。我自己也有一些像我们这样的问题。 –

回答

0

我最好的猜测是:看看你的连接字符串。您可能会传入不支持的选项。仔细检查并交叉参考this page

相关问题