SqlCommand comm = new SqlCommand("select * from smallclass where bigclassid=" + nbigclassid+" order by smallclassid desc", conn);
SqlDataReader adr = comm.ExecuteReader();
string abcd = "";
string defg = "";
if (adr.Read())
{
while (adr.Read())
{
abcd = adr["smallclassid"].ToString().Trim() + "," + abcd;
defg = adr["smallclassname"].ToString().Trim() + "," + defg;
}
Response.Write(abcd);
Response.Write("<br>");
adr.Close();
}程序执行后,明明数据库中有三条记录,abcd字符串应该是"1,2,3,4,"
但是执行的结果却是"1,2,3,"
不知道是什么原因呢?
SqlDataReader adr = comm.ExecuteReader();
string abcd = "";
string defg = "";
if (adr.Read())
{
while (adr.Read())
{
abcd = adr["smallclassid"].ToString().Trim() + "," + abcd;
defg = adr["smallclassname"].ToString().Trim() + "," + defg;
}
Response.Write(abcd);
Response.Write("<br>");
adr.Close();
}程序执行后,明明数据库中有三条记录,abcd字符串应该是"1,2,3,4,"
但是执行的结果却是"1,2,3,"
不知道是什么原因呢?
解决方案 »
- MVC3 Razor 视图页面报System.OutOfMemoryException异常
- ASP.NET 的所有对象中 包含 (web 页 ,标签 等等) 有没有 共有的属性 ?类似于PB 中的 tag 值 那样的东西
- 网站报价问题
- 无法连接到VISUAL STUDIO 的 LOCALHOST WEB 服务器?????怎么回事
- 使用webClient.UploadFile上传文件时,总是提示 远程服务器返回错误:(404)未找到。
- .net的工具箱里可以添加自己写的COM组件,但我添加到C#页面上后,在客户端访问页面并没有出现该组件。asp页面上,怎样才能使用自己做的CO
- 畸形的传值的问题高手们帮忙看看
- css+div+js
- 一个关于sort属性的问题
- 【404错误】【关于404的问题,如何使用自定义的404错误页面!!!!!!!!】
- ajax+gridview 向高手们,高分求教
- 如何给单元格添加控件
SqlDataReader adr = comm.ExecuteReader();
string abcd = "";
string defg = "";
while (adr.Read())
{
abcd = adr["smallclassid"].ToString().Trim() + "," + abcd;
defg = adr["smallclassname"].ToString().Trim() + "," + defg;
Response.Write(abcd);
Response.Write("<br>");
}
adr.Close();