同样,我使用C#连接到表单的Access DB。 代码工作(似乎是这样),但它只显示数据库的第一条记录,在gridview中没有更多。
string connetionString;
OleDbConnection connection;
OleDbDataAdapter oledbAdapter;
DataSet ds = new DataSet();
string Sql;
connetionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Z:\Tempesta\Area Progetto\Area_Progetto_DATA_MAGAZINE\Data_Magazine\Data_Magazine\DB\DataMG.mdb;";
connection = new OleDbConnection(connetionString);
Sql = "select * from Prodotti";
try
{
connection.Open();
oledbAdapter = new OleDbDataAdapter(Sql, connection);
oledbAdapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
怎么了?