问高手个控件绑定数据的问题

wylovemzc 2009-03-09 01:09:35
string coun = "select count(*) as topn from answer where QuestionID1=" + Label1.Text + " and ProjectID1='20090302'";
comm = new OleDbCommand(coun, conn);
OleDbDataReader read6 = comm.ExecuteReader();
if (read6.Read())
{
int topn = Convert.ToInt32(read6["topn"].ToString());
string sql6;
if (randoma == "True")
{
sql6 = "select top " + topn + " * from answer where QuestionID1=" + Label1.Text + " and ProjectID1='20090302' order by rnd(Id)";
}
else
{
sql6 = "select top " + topn + " * from answer where QuestionID1=" + Label1.Text + " and ProjectID1='20090302'";
}
comm = new OleDbCommand(sql6, conn);
OleDbDataReader read7 = comm.ExecuteReader();
if (read7.Read())
{
if (type == "单选")
{
input = read7["Inputable1"].ToString();
if (input == "False")
{
RadioButtonList1.DataSource = read7;
RadioButtonList1.DataTextField = "Answer1";
RadioButtonList1.DataBind();
RadioButtonList1.Visible = true;
}
else
{
RadioButtonList1.DataSource = read7;
RadioButtonList1.DataTextField = "Answer1";
RadioButtonList1.DataBind();
RadioButtonList1.Visible = true;
TextBox2.Visible = true;
TextBox2.Enabled = true;
}
}


正确的应该是4条记录,为什么绑定出来后是3条记录?请各位帮我看看,谢谢
...全文
78 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
满衣兄 2009-03-09
  • 打赏
  • 举报
回复
调试:
1.先确定执行的语句是否正确:可以使用sqlserver自带的事件探察器把页面执行时候的语句抓出来,然后放到查询分析器里执行,看结果是否正确,如果不正确则修改查询语句.
2.如果1没问题,则在程序里打断点调试.

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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