1.建立連接字符串,裡面包含數據庫名稱、用戶名和密碼
2.建立操作字符串,裡面是對數據操作的SQL語句
3.建立Connection,用連接字符串作為參數建立
4.建立Command,用操作字符串和Connection作為參數
5.建立DataAdapter,用Command作為參數
代碼如下:
string cosn = "Data Source=172.20.65.236;User Id=bjmedicare_qy;Password=bjmedicare_qy";
string sql = "select * from test_n";
OracleConnection conn = new OracleConnection(cosn);
OracleCommand cmd = new OracleCommand(sql, conn);
OracleDataAdapter adp = new OracleDataAdapter(cmd);
DataSet dsRet = new DataSet();
adp.Fill(dsRet);
adp.Dispose();
conn.Close();