请教各位
  如:
  string strconn = "server=.;database=sell;integrated security=true;connect Timeout=30";
  SqlConnection conn = new SqlConnection(strconn);
  string strQuery = "select ProID from ProStock";  怎么去获取select查询后所返回的 ProID 值呀?我初学C#请您详细的讲解一下  SqlDataAdapter da = new SqlDataAdapter(strQuery,conn);
  

解决方案 »

  1.   

    string strconn = "server=.;database=sell;integrated security=true;connect Timeout=30";
    SqlConnection conn = new SqlConnection(strconn);
    string strQuery = "select ProID from ProStock";SqlDataAdapter da = new SqlDataAdapter(strQuery,conn);
    DataSet ds= new DataSet();
    da.Fill(ds);
      

  2.   

    那个command有三个读取方法你自己看一下说明有一个就是返回值
      

  3.   

    这要看你是要首行首列值,还是所有行和列的值,如果要所有行和列的值,先要确定你打算什么容器来放这些值,比如到的数据集中,还是数组中,还是集合中,SqlDataAdapter是DataSet专用的,如果需要放到其他容器中的话,应该用SqlCommand和SqlDataReader
      

  4.   

    说出你的目的,否则,回答你这个问题,就只能发一篇完整的ADO.Net教案了,可能500页的书也讲不清楚
      

  5.   

    SqlConnection dcon = new SqlConnection();
                SqlCommand dcom = new SqlCommand();
                SqlDataReader dread=new SqlDataReader();
                string strQuery = "select ProID from ProStock";
                string strconn = "server=.;database=sell;integrated security=true;connect Timeout=30";
                dcon.ConnectionString = strconn;
                dcon.Open();
                dcom.CommandText = strQuery;
                dread = dcom.ExecuteReader();   
                dcon.Close();
                dread.Read();
                int AAA = dread.GetInt32(0); // 这个 AAA 变量里放的就是ProID ,可以用循环读取多行
                dread.Close();
      

  6.   

    用数据集,SqlDataAdapter Da = new SqlDataAdapter("select * from ",conn);
    Da.fill(dataset);然后从dataset中获取
      

  7.   

    用数据集啊  就是 dataset 
      

  8.   

    lz,你的问题不是C#的,你是对ado.net不了解,这个你还是需要系统的去看这方面的书啊