本机跑不起,哎,郁闷啊,
虚拟机里可以
主要是里面有取每个字段的数据的例子
OracleConnection conn = new OracleConnection(); try { conn.ConnectionString = ConfigurationManager.ConnectionStrings["sourcedb"].ConnectionString; conn.Open(); string strSQL = "select * from TB_ZY_SFMXB where rownum<10"; OracleCommand cmd = new OracleCommand(strSQL, conn); OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string line = ""; for (int i = 0; i < reader.FieldCount; i++) { line += reader.GetName(i).ToString() + "=" + reader.GetValue(i).ToString() + " \n"; } jg.AppendText(line); } } catch (Exception ex) { jg.AppendText(ex.Message+"\n"); } finally { conn.Clone(); }
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《c#的odp.net连接oracle的代码》
发表评论