如何用c#读取Access的一列数据?求代码

读取数据后如何将这些数据赋值给一个数组?能不能给一个完整的代码

using System.Data.OleDb;
using System.Data.Common;

OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
OleDbCommand cmd = new OleDbCommand("select Col1 from table", con);

this.GridView1.DataSource = cmd.ExecuteReader();
this.GridView1.DataBind();

OleDbDataAdapter sda = new OleDbDataAdapter("select xinghao from product", con);
con.Open();
DataSet ds = new DataSet();
sda.Fill(ds, "product");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string[] shuzu ;
shuzu = new string[ds.Tables[0].Rows.Count];
shuzu[i] = ds.Tables[0].Rows[i]["xinghao"].ToString();
Response.Write(shuzu[i]);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-09-05
select * from tableName
第2个回答  2011-09-04
直接用SQL语句就可以了,查询出来一列即可。
select ×× from tablename
相似回答