2017-02-21 104 views
0

我已經成功地構建連接字符串,並能夠填充表數據時,數據庫是Access爲:填充數據表 - C#

DataTable results = new DataTable(); 
using (OleDbConnection thisConnection = new OleDbConnection(connectionname)) 
      { 
       OleDbCommand cmd = new OleDbCommand("SELECT * from TABLE_A", thisConnection); //EDIT : change table name for Oracle 
       thisConnection.Open(); 
       OleDbDataAdapter adapter = new OleDbDataAdapter(cmd); 
       adapter.Fill(results); 
      } 

我是新來的Oracle雖然。有人可以提到在上面的Oracle數據庫代碼中做出什麼改變嗎?

+0

是的,但如何? @ChrisCruz – user7157732

回答

2

你可以試試這個;

OracleConnection conn = new OracleConnection("Your Connection string"); 

Conn.Open; 

DataSet dataSet = new DataSet(); 

OracleCommand cmd = new OracleCommand("your select query"); 

cmd.CommandType = CommandType.Text; 

cmd.Connection = conn; 

using (OracleDataAdapter dataAdapter = new OracleDataAdapter()) 
{ 
    dataAdapter.SelectCommand = cmd; 
    dataAdapter.Fill(dataSet); 
}