[問題] 怎麼利用datagrid顯示access的資料
如題…
有上網找了一些並拿來試
但就是不成功>"<
程式碼如下
OleDbConnection Database_Con = null;
try
{
OleDbConnectionStringBuilder con_string =
new OleDbConnectionStringBuilder();
con_string.Provider = "Microsoft.ACE.OLEDB.12.0";
con_string.DataSource = @"setLocation.accdb";
Database_Con = new
OleDbConnection(con_string.ConnectionString);
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to Create a Database Connection." + ex.Message);
}
try
{
setLocationDataSet da = new setLocationDataSet();
OleDbCommand Select = new OleDbCommand();
Select.CommandType = System.Data.CommandType.Text;
Select.CommandText = "Select * from set1";
Select.Connection = Database_Con;
OleDbDataAdapter data = new
OlebDataAdapter(Select.CommandText,Database_Con);
data.SelectCommand = Select;
data.Fill(da,"set1");
dataGrid1.ItemsSource = da.Tables;
//Select.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to retrieve the required
data from the DataBase.\n" + ex.Message);
}
finally
{
Database_Con.Close();
}
還有請哪位大大指點一下>"<
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 58.115.143.87
→
09/28 07:16, , 1F
09/28 07:16, 1F
→
09/28 08:57, , 2F
09/28 08:57, 2F
推
09/28 13:39, , 3F
09/28 13:39, 3F
→
09/28 13:41, , 4F
09/28 13:41, 4F
推
10/06 18:15, , 5F
10/06 18:15, 5F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章