gpt4 book ai didi

c# - npgsql抛出错误的异常信息

转载 作者:行者123 更新时间:2023-11-29 11:52:03 32 4
gpt4 key购买 nike

我的数据库脚本如下。

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: _

我知道我在 NOT NULL 列中传递了 NULL 值。我想得到确切的错误信息。上面的错误到底是什么意思?

最佳答案

我的最佳猜测:查看您的连接字符串。您可能在那里传递了一个不受支持的选项。使用 this page 仔细检查和交叉引用.

关于c# - npgsql抛出错误的异常信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628073/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com