"select 采购单号 from 表 order by 采购单号".bool bln= false; for (int i=0;i<dataTable.rows.count:i++) { if (i==0) { Response.Write(dataTable.rows[i]["采购单号"]); } else if { if (dataTable.rows[i]["采购单号"]==dataTable.rows[i-1]["采购单号"]) { Response.Write("----------"); } else { Response.Write(dataTable.rows[i]["采购单号"]); } } }
bool bln= false;不要。
如果"采购单号"是字符型不用“==”而用"equals"
for (int i=0;i<ds.Tables["Pur"].Rows.Count;i++) { if (i==0) { Response.Write(ds.Tables["Pur"].Rows[i]["pono"]); } else { if (ds.Tables["Pur"].Rows[i]["pono"] == ds.Tables["Pur"].Rows[i-1]["pono"]) { Response.Write("----------"); } else { Response.Write(ds.Tables["Pur"].Rows[i]["pono"]); } } }楼上的啊,怎么输出的是:QM5300002QM5300002QM5300002QM5300002 ?????????????
public string CheckRepter(int j,string NowStr,string PreStr)
{
if(j == 0)
{
return NowStr;
}
else
{
if(NowStr == PreStr)
return "-------";
else
return NowStr;
}
}
你要显示出来,肯定是循环的
while(dr.read())
{
if(getName(dr["采购单号"])==1)
{
Response.Write(dr["采购单号"]+"----------");
}
else
{
Response.Write(dr["采购单号"]);
}
}
写个函数判断
public int getName(string str)//str是当前采购单号
{
//然后从数据库里COUNT下这个采购单号
SQL语句:select count(采购单号) from 表名 where 采购单号=str
判断如果大于一 return 1
否则 return 0
}
不知道你明白没有。把思路在说一下。 就是先检索单一的采购单号。然后写个判断函数,这个函数以当前采购单号当参数,然后进行汇总检索,如果总和大于一条记录,那就返回1否则返回0
然后开始显示,判断采购单号的汇总大于一就加”---------“ 否则直接打印采购单号
采购单号
QM000001
QM000001
QM000001
QM000001现在我想变成如下形式:采购单号
QM000001
--------
--------
--------
这个不是我想要的
for (int i=0;i<dataTable.rows.count:i++)
{
if (i==0)
{
Response.Write(dataTable.rows[i]["采购单号"]);
}
else if
{
if (dataTable.rows[i]["采购单号"]==dataTable.rows[i-1]["采购单号"])
{
Response.Write("----------");
}
else
{
Response.Write(dataTable.rows[i]["采购单号"]);
}
}
}
{
if (i==0)
{
Response.Write(ds.Tables["Pur"].Rows[i]["pono"]);
}
else
{
if (ds.Tables["Pur"].Rows[i]["pono"] == ds.Tables["Pur"].Rows[i-1]["pono"])
{
Response.Write("----------");
}
else
{
Response.Write(ds.Tables["Pur"].Rows[i]["pono"]);
}
}
}楼上的啊,怎么输出的是:QM5300002QM5300002QM5300002QM5300002 ?????????????