小弟我新手,看见一个例子代码如下:
DataSet ds = new DataSet();
myCommand.Fill(ds);
// Bind MyDataGrid to the DataSet. MyDataGrid is the ID for the 
// DataGrid control in the HTML section.
DataView source = new DataView(ds.Tables[0]);
DataGrid.DataSource = source ;
DataGrid.DataBind();他这里用的是ds.Tables[0],我如果再加类似如下代码:
anotherCommand.Fill(ds)
那么我anotherCommand查询得到的表是否是ds.Tables[1]?

解决方案 »

  1.   

    你在使用Fill方法的时候,要加上临时表名,就很容易区分了,例如:
    myCommand.Fill(ds, yourTableName );//Fill table with nameDataView source = new DataView(ds.Tables[yourTableName]);//Create data view using name.
      

  2.   

    to anotherCommand.Fill(ds)
    那么我anotherCommand查询得到的表是否是ds.Tables[1]?如果想放到一起,按照我上面提的,用同一个表名即可,如果不想放到一起,用另外一个表名。
    这样程序看得很清楚。
      

  3.   

    对呀。一般是不建议用table[0]这样的方式的,因为当只有一个表的时候这样很好用。但是当表多了的时候就能麻烦了。不如直接给表命名来的方便,也不容易出错。
    方法就是楼上的那样。
    this.sqldataadapter1.fill(this.dataset1,"myTablename")调用就简单了:
    dataview source=this.dataset1.table["myTablename"].defaultview;
      

  4.   

    谢谢楼上各位朋友,我了解了,这个和SESION类似,自己定义个str好理解些~