Dal*_*lal 1 c# postgresql npgsql
我正在使用带有C#的Npgsql与我的PostgreSQL数据库进行通信.我的数据库中使用的所有名称都是大小写混合,因此在查询中我确保在每个名称周围使用双引号.以下是我发送查询的方式:
// construct an insert query
string insertQuery = "insert into \"Update\" (\"Vehicle\",\"Property\",\"Value\") " +
"values (" + vehicleNum.ToString() + ",\"" + propertyName +
"\",\"" + propertyValue + "\")";
// execute the query
NpgsqlCommand insertCommand = new NpgsqlCommand(insertQuery, conn);
insertCommand.ExecuteScalar();
Run Code Online (Sandbox Code Playgroud)
通过插入断点并进行检查,我验证了字符串insertQuery在发送之前看起来是这样的:
insert into "Update" ("Vehicle","Property","Value") values (12345,"EngineSpeed","50")
Run Code Online (Sandbox Code Playgroud)
当我发送这个查询时,PostgreSQL给了我一个错误,它包含在一个Npgsql异常中,该异常指出: ERROR: 42703: column "EngineSpeed" does not exist
从我的查询中可以看出,EngineSpeed它不是列,它是列的值Property,因此具有该名称的列自然不可能存在.那么为什么PostgreSQL以这种方式处理我的查询,我该如何解决这个问题呢?我的查询是否以错误的方式构建?
| 归档时间: |
|
| 查看次数: |
2235 次 |
| 最近记录: |