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: _
我知道我传递NULL值NOT NULL柱。我想获得确切的错误信息。上述错误意味着什么?
你只是偶然使用PostgreSQL 9.3?众所周知的是(在邮件列表中)除了最新版本的Npgsql之外,其他所有版本的PostgreSQL都会抛出一些错误的异常并表现出奇怪的行为。我自己也有一些像我们这样的问题。 –