所以我在C#后面的代码中有一个Select语句:
Select username from vw_members where username = 'SomeValue'
但是这会在我的aspx页面上返回此错误:列“username”不存在
如果我在pgAdmin SQLEditor中运行相同的语句,则运行没问题
如果我在后面的代码上运行这样的东西:
Select username from tbl_users where username = 'SomeValue'
运行良好。
视图是与用户表和成员表的连接。 这是我的C#代码:
string selectstmt = "Select UserName from vw_members where UserName = 'SomeValue'";
我在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;
答案 0 :(得分:1)
有人建议我查看是否已启用 区分大小写的列排序规则 ,并且结果显示它已启用。从那里我确保我的所有列名都匹配相同的情况,之后一切正常。
答案 1 :(得分:0)
尝试在视图中使用显式联接:
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
可能没有任何区别,但这是值得尝试的。