PostgreSql数据库中users_table表中,userId字段为BIGINT数据类型,唯一,不为空。我正在使用 Npgsql 6.0.2
控制台错误: invalid input syntax for type double precision: "userId"或недопустимый синтаксис ввода для типа двойной точности
编码:
conn.Open();
NpgsqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT @'userId' FROM users_table";
NpgsqlDataReader reader = command.ExecuteReader();
List<string[]> data = new List<string[]>();
while (reader.Read())
{
data.Add(new string[1]);
data[data.Count - 1][0] = reader[0].ToString();
}
reader.Close();
conn.Close();

命名表或字段时不要使用大写字母。在我的情况下,我命名了该字段
user_id,即使没有 @ 和 '' 也一切正常