改成这样访问:DBAccess dba = new test.db.DBAccess();
ds = dba.Query("select ProductID,ProductName from Products");
int aa = ds.Tables[0].Rows.Count;
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
不然你的test.db.DBAccess组件这样改:
public DataSet Query(string sqlstr,string TableName)
{
...
SqlDataAdapter.Fill(DataSetName,DataTableName);
return DataSetName;
}
然后才调用
ds = dba.Query("select ProductID,ProductName from Products","Products");
int aa = ds.Tables["Products"].Rows.Count;
TextBox1.Text = ds.Tables["Products"].Rows[0][0].ToString();
ds = dba.Query("select ProductID,ProductName from Products");
int aa = ds.Tables[0].Rows.Count;
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
不然你的test.db.DBAccess组件这样改:
public DataSet Query(string sqlstr,string TableName)
{
...
SqlDataAdapter.Fill(DataSetName,DataTableName);
return DataSetName;
}
然后才调用
ds = dba.Query("select ProductID,ProductName from Products","Products");
int aa = ds.Tables["Products"].Rows.Count;
TextBox1.Text = ds.Tables["Products"].Rows[0][0].ToString();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货