object o=cmd1.ExecuteScalar();
if (o!=null)
{
   Response.Write(o["库存总量"].ToString());
}

解决方案 »

  1.   

    SqlDataReader r;
    SqlConnection conn = new SqlConnection(ConnectionString);
    comm.ActiveConnection = conn;conn.Open();
    r=comm.ExecuteReader();while(r.Read())
    {
        Response.Write(r["库存总量"].ToString());
    }
      

  2.   

    方法一:
    OleDbDataReader ObjRS = cmd1.ExecuteReader();
    while(ObjRS.Read()){
    Console.WriteLine(ObjRS[0]);
    }
    ObjRS.Close();方法二:
    DataSet ObjDS = new DataSet();
    cmd1.Fill(ObjDS,"表1");
    ObjConn.Close();
    int MaxRecoard = ObjDS.Tables["Indexs"].Rows.Count;
    for (int i=0;i<MaxRecoard;i++){
    DataRow ObjRS = ObjDS.Tables["表1"].Rows[i];
    Console.WriteLine(ObjRS[0]);
    }
      

  3.   

    方法二中的
    int MaxRecoard = ObjDS.Tables["Indexs"].Rows.Count;
    写错了,应为
    int MaxRecoard = ObjDS.Tables["表1"].Rows.Count;我推荐用OleDbDataReader (oledb 兼容性和扩展性好,包括oracle和excel) 不要用dataset 资源狂的很,除非数据集比较大