例如:
string strQuery="select fField from yourtable";
SqlDataAdapter sqlDAdapter=new SqlDataAdapter(strQuery,sqlConn);
//sqlConn is your connection
DataSet sqlRecordSet=new DataSet();sqlDAdapter.Fill(sqlRecordSet,"tempTable");
float fData;
foreach (DataRow myDataRow in sqlRecordSet.Tables["tempRequestInfo"].Rows)
{
//Storage info in buffer
fData=(float)myDataRow["fField"];
         MessageBox.Show(fData.ToString());
}
sqlRecordSet.Dispose();
sqlDAdapter.Dispose();

解决方案 »

  1.   

    MessageBox.Show(fData.ToString());这个是什么意思?
    float fData;这个你定义的是一个数组吗?
      

  2.   

    To float fData;这个你定义的是一个数组吗?是定义一个float类型的变量To MessageBox.Show(fData.ToString());
    只是为了显示,没别的意思,你如果想获得值,那么在fData=(float)myDataRow["fField"];之后就可以用了。如果想用OleDB的,那么把SqlDataAdapter改为OleDbDataAdapter就行了。
      

  3.   

    SqlConnection conn=new SqlConnection (@"xxx");
    DataSet ds=new DataSet();
    SqlDataAdapter da=new SqlDataAdapter(("SELECT name FORM TABLE1",conn);
    da.Fill(ds,"TABLE1");
    float fList=new float[ds.Table["TABLE1"].Rows.Count];
    for(int i;i< ds.Table["TABLE1"].Rows;i++)
    {
         fList[i]=ds.Table["TABLE1"].Rows[i]["name"];
    }
      

  4.   

    OleDbConnection conn=new OleDbConnection (@"xxx");
    DataSet ds=new DataSet();
    OleDbDataAdapter da=new OleDbDataAdapter(("SELECT name FORM TABLE1",conn);
    da.Fill(ds,"TABLE1");
    float fList=new float[ds.Table["TABLE1"].Rows.Count];
    for(int i;i< ds.Table["TABLE1"].Rows;i++)
    {
         fList[i]=ds.Table["TABLE1"].Rows[i]["name"];
    }
      

  5.   

    float fList=new float[ds.Table["TABLE1"].Rows.Count];这个是在定义数组吗?不应该是float[] fList;吗?