一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

.net+oracle+crystalReports开发web应用程序学习笔记(二)

时间:2008-02-11 编辑:简简单单 来源:一聚教程网

上次提到基本的配置注意问题,现在开始实际开发oracle中的问题
一 oracle 数据库的连接
但你装了oracle的客户端,在配置时就已经指定了数据库服务器,所以连接时主要由三个元素就可以连接上数据库,数据库的名称(即SID),用户名,密码
SqlConnection con=new SqlConnection("Provider=MSDAORA.1;User ID=UserID;Data Source=xf;Password=password")
而sql Server不需要安装客户端,所以必须指定服务器,和数据库名
SqlConnection con=new SqlConnection("workstation id=XIAOFENG;packet size=4096;user id=sa;integrated security=SSPI;data source=xiaofeng;persist security info=False;initial catalog=xf");
二 在oracle中运行包(Package)中的函数和存储过程。
举个例子,要运行下面一个sql语句:"select order_no,inventory_part_api.get_description(contract,part_no),part_no from SHOP_ORD where inventory_part_api.get_description(contract,part_no) like '%喜之郎25%果冻%'";
1.在.net设计中(如设计sqlDataAdapter)不能够直接使用包中的函数和存储过程,如果要使用,可以在设计时把包中要使用的函数和存储过程copy过来再设计时声明一遍,就可以使用
2.在.net运行时直接添加代码,系统会直接去寻中包中的内容
string strCommand;
strCommand="select order_no,inventory_part_api.get_description(contract,part_no),part_no from SHOP_ORD where inventory_part_api.get_description(contract,part_no) like '%喜之郎25%果冻%'";
OleDbConnection con=new OleDbConnection("Provider=MSDAORA.1;Password=password;User ID=UserID;Data Source=xf");
con.Open();
OleDbDataAdapter adapter=new OleDbDataAdapter(strCommand,con);
DataSet dataset = new DataSet();

热门栏目