.net 訪問Oracle

來源:互聯網
上載者:User

http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html



1.
發布時需要包括下面的dll
http://www.189works.com/article-58367-1.html
或者下載oracle ODAC 的xcopy版,運行install.bat all c:\oracle odac 進行安裝

2.
可以使用EF,參數化查詢時使用:paramName

View Code

        private void button4_Click(object sender, EventArgs e)        {            var cmdText=@"select e.empno, e.ename, e.hiredate, d.dname from scott.emp e inner join scott.dept d                         on e.deptno=d.deptno                          where d.deptno=:deptno";            var ctx = new Entities();            var list= ctx.ExecuteStoreQuery<EmpInfo>(cmdText,20).ToList();        }    }    public class EmpInfo    {        public int EMPNO { get; set; }        public string EName { get; set; }        public DateTime HireDate { get; set; }        public string DName { get; set; }    }

3.
串連可以這麼寫:
string connstring = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.30)(PORT=1521)) (CONNECT_DATA=(SID=ORCL)));User Id=scott;Password=password;"
也可以這樣:
string connstring = "Data Source=192.168.1.30:1521/ORCL;User Id=scott;Password=password;"
以管裡員身份登入:
 string connstring = "Data Source=192.168.1.30:1521/ORCL;User Id=Sys;Password=admin;DBA Privilege=SYSDBA;";

4.
使用 Oracle Net Configuration Assistant 可以配置Oracle串連連接埠,老連不上的話,可以用這個試試

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.