日期:2014-05-18 浏览次数:20870 次
OracleConnection m_Conn = new OracleConnection(); m_Conn.ConnectionString = string.Format("DATA SOURCE={0};PERSIST SECURITY INFO=True;USER ID={1}; PASSWORD={2}", DataSource, UserName, Password); /// <summary> /// 根据SQL语句返回相应的表 /// </summary> /// <param name="Sql"></param> /// <param name="TableName"></param> /// <returns></returns> public DataTable GetDataTable(string Sql) { DataTable pDataTable; OracleDataAdapter pOracleDataAdapter; m_Conn.Open(); pOracleDataAdapter = new OracleDataAdapter(Sql, m_Conn); pDataTable = new DataTable(); try { pOracleDataAdapter.Fill(pDataTable); return pDataTable; } catch (OracleException exp) { MessageBox.Show("执行SQL出现错误:" + exp.Message); return null; } }