Select a.sj As sj1,b.sj As sj2
From tb1 a 
Join tb2 b On tb1.bh = tb2.bh比较每条记录的sj1和sj2

解决方案 »

  1.   

    for(int i=0;i<tb1.Rows.Count;i++)
    {
    大值=tb1.Rows[i]["sj"]>tb2.Rows[i]["sj"]?tb1.Rows[i]["sj"];tb2.Rows[i]["sj"];
    }
      

  2.   

    if(int.prase(ds.Tables["tb1"].rows[i]["sj"])>int.prase(ds.Tables["tb2"].rows[i]["sj"]))
    {
    }
      

  3.   

    用sql语句比较:select A.sj,b.sj,cast(A.sj as int)-cast(b.sj as int) as Diffrnece from 
    From tb1 a  left Join tb2 b On tb1.bh = tb2.bh
    或者用你所说的数据集:
    string bh;
    foreac(DataRow r in ds.Tables["tb1"].Rows)
    {
      bh= r["bh"].tostring();
      int temp1= System.Convert.toInt32(r["sj"].tostring());
       DataRow[] foundRows = 
            ds.Tables["tb2"].Select("bh='"+bh+"'");
      int temp2 =System.Convert.toInt32(foundRows[0]["sj"]tostring());
     if(temp1>temp2)
     
    {
     //判断的结果
    }}