sq = "select roomno,blockname from roommanage where roomno not in( select *from availableroom)";
ds = dc.filldata(sq);
GridView1.DataSource = ds.Tables["t1"];
GridView1.DataBind();
有一个错误:
Only one expression can be specified in the select list when the subquery is not introduced with EXIST
。
我该如何解决这个问题?
答案 0 :(得分:0)
在你的“不在”中应该只返回1列。请尝试以下代码。
sq = "select roomno,blockname from roommanage where roomno not in( select id from availableroom)";
ds = dc.filldata(sq);
GridView1.DataSource = ds.Tables["t1"];
GridView1.DataBind();
答案 1 :(得分:0)
两列试试这个
sq = "SELECT roomno,blockname FROM roommanage
WHERE roomno NOT IN( SELECT id FROM availableroom)
AND blockname NOT IN(SELECT yourcolumn FROM blockname)";
ds = dc.filldata(sq);
GridView1.DataSource = ds.Tables["t1"];
GridView1.DataBind();