public CommentBO(string channel, string volumn)
{
//CommentContent = TableQuery.CommentQuery(channel, volumn);
//dt = TableQuery.CommentQuery(channel, volumn);
CommentContent = " <div id=\"newsphoto\">";
CommentContent += " <img src=\"pic/newspic.jpg\" width=\"240\" height=\"180\" class=\"newspic\"/>";
CommentContent += " </div>";
CommentContent += " <div id=\"newstitle\">";
CommentContent += " <ul>";
OleDbDataAdapter da = new OleDbDataAdapter("select top 9 articles.id,articles.title,articles.update,articles.hit from articles where channel='pe' and column='news'",conn);
ds=new DataSet();
//dt=new DataTable();
//try
//{
da.Fill(ds,"dt");
//}
//catch (Exception ex)
//{
//throw ex;
//}
//finally
//{
//da.Dispose();
//}
for (int i = 0; i < ds.Tables["dt"].Rows.Count; i++)
{
CommentContent += "<li>" + StringManager.StringCut(ds.Tables["dt"].Rows[i][1].ToString(),19) + " [" + StringManager.TimeMessage(ds.Tables["dt"].Rows[i][2].ToString())+ "]" +
"</li>";
}
CommentContent += " </ul>";
CommentContent += " </div>";
}
问这个问题真的不好意思。问题出在:where channel='pe' and column='news',我就纳闷了,怎么就错了呢?
------解决思路----------------------
把你的sql改成这样试试
select top 9 id,title,[update],hit from articles where channel='pe' and [column]='news'
------解决思路----------------------
column 是保留字,这样试试
where [channel]='pe' and [column]='news'
------解决思路----------------------
正解
------解决思路----------------------
虽然是保留字的问题,但楼主你最好还是将表字段名改一下为好,不建议用保留字做字段名,表名也是如此。
这里有关于sqlserver的保留字介绍,你可以看看
http://www.cnblogs.com/no7dw/archive/2010/04/23/1718246.html