遗忘海岸

江湖程序员 -Feiph(LM战士)

导航

.net 访问Oracle

http://www.oracle.com/technetwork/cn/database/windows/downloads/index-098472-zhs.html 64

下载地址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连接端口,老连不上的话,可以用这个试试

 

posted on 2012-11-19 15:22  遗忘海岸  阅读(251)  评论(0编辑  收藏  举报