看板 C_Sharp 關於我們 聯絡資訊
如題… 有上網找了一些並拿來試 但就是不成功>"< 程式碼如下 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
taoko:exception寫什麼? 09/28 07:16
darkian:沒出現exception,會是datagrid那邊的問題嗎? 09/28 08:57
rex1224:你用dataset的時候沒告訴他你要用哪張table 09/28 13:39
rex1224:像是da.Tables[1] 09/28 13:41
yes302:dataGrid1.ItemsSource = da.Tables <=這... 10/06 18:15