.net+oracle+crystalReports开发web应用程序学习笔记(二)
一 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();
adapter.Fill(dataset);
this.DataGrid1.DataSource=dataset;
DataGrid1.DataBind();
con.Close();
3.怎么使用存储过程
OracleConnection conn = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");
Conn.Open;
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "sp_pkg.getdata";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("a1", OracleType.Cursor)).Direction = ParameterDirection.Output;
cmd.Parameters.Add(new OracleParameter("a2", OracleType.Cursor)).Direction = ParameterDirection.Output;
DataSet ds = new DataSet();
OracleDataAdapter adapter = new OracleDataAdapter(cmd);
adapter.Fill(ds);
下一篇:使用.net Remtoing进行并行计算 >>
相关文章:
- · 创建插件框架(1)
- · 来自开源社区的声音: .NET vs JAVA
- · .net下分层架构系统的开发技术规范(2)
- · 在.NET 中模拟提交Post数据
- · 以武學的視角來戲說.NET程序員的倚天之術
- · XP方法学习总结及对小组开发的思考
- · 程序员的.NET时代(二)
- · 程序员的.NET时代(一)
- · 品味.NET巨著——书评《Microsoft .NET框架程序设计(修订版)》
- · 解决.NET(WebApplication)安装部署的不能选择安装路径的问题
- · Beta 1 到 Beta 2 改变详细列表(英文)Beta 1 to Beta 2 Changes
- · Microsoft Visual J#.NET (JSharp) Version 7.0 Beta 1 out
- · Microsoft Visual Studio.NET及Borland Delphi6初探
- · .NET对软件安装的冲击
- · Microsoft Tech Ed
- · .NET 和 COM 之间的相互访问
- · 介绍.NET中的委派(一)
- · .NET架构的核心开发技术
- · 控制VC++.NET中WEB对话框的HTML元素属性
- · Borland Eyeing the Chasm Between Java and .NET
- · .Net 是未来的趋势, 为什么?
- · Microsoft .NET Development Platform的Linux版本(Mono)出现
- · 价值上千美元的Visual Studio.NET β2的培训
- · 使用 Microsoft.NET Frameworks 创建Windows应用程序
- · DataGrid连接Access的快速分页法(1)——需求与现状
- · 用Socket类构建网页下载器
- · COM与.NET的互操作(初级)
- · .NET 的对象关系持久化机制(1)
- · Websharp使用说明(8)
- · Websharp使用说明(7)
- · Websharp使用说明(6)
- · Websharp使用说明(5)
- · Websharp使用说明(4)
- · Websharp使用说明(3)
- · Websharp使用说明(2)
- · Websharp使用说明(1)
- · 使.NET命名空间符合标准
- · Repeater控件的分页问题
