一个简单的问题,高手请帮忙
string sendsql = "select * from table ";
SqlDataAdapter da = new SqlDataAdapter(sendsql, conn);
DataSet1 ds = new DataSet1();
da.Fill(ds, "tb16 ");
if (ds.Tables[ "tb16 "].Rows.Count > 0)
{
MessageBox.Show(ds.Tables[ "tb16 "].Rows[0][0].ToString());
}
就是一个简单的取值问题,为什么明明tb16中有值,但是却取不到,我想取出其中第0行0列的值,应该怎么取?高手帮忙!!!
------解决方案--------------------这代码不是楼主现在用的吧?
DataSet1 ds = new DataSet1();能编译过去?
------解决方案--------------------cmd.ExecuteScalar();
------解决方案--------------------string sendsql = "select * from table ";
SqlDataAdapter da = new SqlDataAdapter(sendsql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "tb16 ");
if (ds.Tables[0].Rows.Count > 0)
{
MessageBox.Show(ds.Tables[0].Rows[0].ItemArray[3].ToString());
}
应该是这样吧,DataSet1 ds = new DataSet1();肯定不正确.
------解决方案--------------------DataSet ds=new DataSet();
string strsql = "select * from XXXX ";
SqlConnection conn=new SqlConnection();
SqlDataAdapter dt=new SqlDataAdapter(strsql,conn);
conn.ConnectionString = "server=XXX;uid=XX;pwd=XX;database=XX ";
conn.Open();
dt.Fill(ds);
------解决方案--------------------LZ拖控件的吧..这样不好