简体   繁体   English

C#与SQLEditor — Npgsql.PostgresException 42703:“用户名”列不存在

[英]C# vs SQLEditor — Npgsql.PostgresException 42703: column “username” does not exist

So on my behind code in C# I have a Select Statement: 因此,在C#中的后台代码中,我有一个Select语句:

Select username from vw_members where username = 'SomeValue'

But that returns this error on my aspx page:column "username" does not exist 但这会在我的aspx页面上返回此错误:列“用户名”不存在

If I run that same statement in the pgAdmin SQLEditor it runs no problem 如果我在pgAdmin SQLEditor中运行同一条语句,则不会有问题

If I run something like this on my behind code: 如果我在我的背后代码上运行以下代码:

Select username from tbl_users where username = 'SomeValue'

Runs fine. 运行良好。

The view is a join with the user table and a members table. 该视图是与用户表和成员表的联接。 here is my C# code: 这是我的C#代码:

string selectstmt = "Select UserName from vw_members where UserName = 'SomeValue'";

My View in pgAdmin looks like: 我在pgAdmin中的视图如下所示:

SELECT tbl_member.usertype AS "usertype",
    tbl_member.userid AS "userid",
    tbl_member.createdate AS "createdate",
    tbl_member.lastlogindate AS "lastlogindate",
    tbl_member.email AS "email",
    tbl_users.userid AS "usersid",
    tbl_users.username AS "username",
    tbl_users.lastactivitydate AS "lastactivitydate"
   FROM tbl_users,
    tbl_member
  WHERE tbl_users.userid = tbl_member.userid;

It was suggested I have a look to see if case sensitive column collation was enabled and turns out it is enabled. 建议我看看是否启用了区分大小写的列排序规则 ,事实证明它已启用。 From there I made sure all my column names match in the same case, after that everything is working. 从那里,我确保所有列名称在相同情况下都匹配,然后一切正常。

Try using an explicit join in your view: 尝试在您的视图中使用显式联接:

SELECT tbl_member.usertype AS "usertype",
    tbl_member.userid AS "userid",
    tbl_member.createdate AS "createdate",
    tbl_member.lastlogindate AS "lastlogindate",
    tbl_member.email AS "email",
    tbl_users.userid AS "usersid",
    tbl_users.username AS "username",
    tbl_users.lastactivitydate AS "lastactivitydate"
FROM tbl_users LEFT OUTER JOIN tbl_member
    ON tbl_users.userid = tbl_member.userid

May not make any difference, but it is something to try. 可能没有任何区别,但是可以尝试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Npgsql.PostgresException:关系“表名”不存在' - Npgsql.PostgresException: relation "tablename" does not exist' c#中的Postgresql Npgsql.PostgresException - Postgresql Npgsql.PostgresException in c# Npgsql.PostgresException (0x80004005): 42883: 运算符不存在: jsonb #> text - Npgsql.PostgresException (0x80004005): 42883: operator does not exist: jsonb #> text Npgsql.PostgresException:'42P01:关系“表”不存在” - Npgsql.PostgresException: '42P01: relation “table” does not exist' 尝试在 C# Winform 中查询 PostgreSQL 数据库时,ExecuteReader 出现 Npgsql.PostgresException 错误 - Npgsql.PostgresException error on ExecuteReader when attempting to query PostgreSQL database in C# Winform EF Core 异常:Npgsql.PostgreException:'42703' 列 c1.Index 不存在 - EF Core exception : Npgsql.PostgreException: '42703' Column c1.Index does not exist Npgsql.PostgresException 过程未找到异常 - Npgsql.PostgresException procedure not found exception Npgsql.PostgresException:'55000:在此会话中尚未定义序列“ student_folio_id_seq”的当前时间” - Npgsql.PostgresException: '55000: currval of sequence “student_folio_id_seq” is not yet defined in this session' Npgsql.PostgresException: '28P01: 即使密码正确,密码验证也失败 - Npgsql.PostgresException: '28P01: password authentication failed for use even with the right password 连接到 Redshift 集群时出错 - Npgsql.PostgresException: 28000: no pg_hba.conf entry for host - Error connecting to Redshift Cluster - Npgsql.PostgresException: 28000: no pg_hba.conf entry for host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM