求救!会SQL的请进来,一行转列语句

dbkite 2009-05-01 03:43:33
string xuehao = listView1.Items[listView1.FocusedItem.Index].Tag.ToString().Trim();
string xq = comboBox3.Text.Trim();
//行转列
string sql = "select a.score as Java程序设计,b.score as 大学英语,c.score as 高级代数,d.score as Access数据库,(a.score + b.score + c.score +d.score) as total from((scoreinfo as a inner join scoreinfo as b on a.ScoreID=b.ScoreID) inner join scoreinfo as c on a.ScoreID=c.ScoreID) inner join scoreinfo as d on a.ScoreID=d.ScoreID where studentnumber=" + xuehao + " and semester=" + xq + " ";

OleDbDataAdapter adp = new OleDbDataAdapter(sql, connection1);
ds = new DataSet();
adp.Fill(ds,"score"); //出错的位置
//该特定字段'studentnumber'可以参考SQL语句中FROM子句列表中的多个表。

请高手帮我看看是哪里出错
...全文
115 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
myrroom 2009-05-04
  • 打赏
  • 举报
回复
也来学习
a13vf2 2009-05-04
  • 打赏
  • 举报
回复
不会哦,不过学习学习下也好呀
清风net 2009-05-04
  • 打赏
  • 举报
回复
不会``学习
wuyq11 2009-05-01
  • 打赏
  • 举报
回复
确定studentnumber属于哪个表
amandag 2009-05-01
  • 打赏
  • 举报
回复
估计你的多个表有studentnumber字段,明确地写a.studentnumber或者b.studentnumber..
datafansbj 2009-05-01
  • 打赏
  • 举报
回复
行转列的简单方法应该使用Case语句(SQL Server)
Garnett_KG 2009-05-01
  • 打赏
  • 举报
回复

string sql = "select a.score as Java程序设计,
b.score as 大学英语,
c.score as 高级代数,
d.score as Access数据库,
(a.score + b.score + c.score +d.score) as total
from (
(
scoreinfo as a inner join scoreinfo as b
on a.ScoreID=b.ScoreID
)
inner join scoreinfo as c
on a.ScoreID=c.ScoreID
)
inner join scoreinfo as d
on a.ScoreID=d.ScoreID
where a.studentnumber=" + xuehao + " and a.semester=" + xq + " ";

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧