string sql="select myfield1 from mytable where id='"+sID+"'";//指定某一行的条件
SqlCommand cmd=new SqlCommand(sql,conn);
DataReader reader=cmd.ExecuteReader();
conn.Open();
string sResult;
where(reader.Read())
{
  sResult=reader.GetValue(...);
}
reader.Close();
conn.Close();
大致是这样的,你可以差一下MSDN

解决方案 »

  1.   

    补充一下:
    SqlCommand cmd2=new SqlCommand(s,Conn);
    SqlDataReader read=cmd2.ExecuteReader();
    while(reader.Read())
    {
    reader.GetString(0);
    //或 read.GetString(0);
    }
      

  2.   

    什么意思?
    是指按读出记录集的顺序得到其中某一行某一列值?那试试下面两句SQL吧
    select INDENTITY(int,1,1) AS ID_NUM,列名 into #temp from 表
    Select 列名 from #temp where ID_NUM =你要的行号
      

  3.   

    建一个SqlDataAdapter(SqlDa)连接到你的Sql Server的一个表上DataSet ds_target = new DataSet();
    SqlDa.Fill(ds_target,"test");
    ds_target.Tables["test"].Rows[某一行][某一列] = 你要取得值
    你的系统中不会真这么用吧!
      

  4.   

    public void ReadMyData(string myConnString) {
        string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
        SqlConnection myConnection = new SqlConnection(myConnString);
        SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
        myConnection.Open();
        SqlDataReader myReader;
        myReader = myCommand.ExecuteReader();
        // Always call Read before accessing data.
        while (myReader.Read()) {
           Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
        }
        // always call Close when done reading.
        myReader.Close();
        // Close the connection when done with it.
        myConnection.Close();
     }
      

  5.   

    3ks for all your help