. Net+oracle+crystalreports Development Web Application Learning Notes (ii)

Source: Internet
Author: User
Tags oracleconnection oracle database
Oracle|web| Notes | The program last mentioned basic configuration considerations and now begins to actually develop problems in Oracle

A connection to an Oracle database

But you installed the Oracle client, the database server has been specified at the time of configuration, so the connection can be made up of three elements, the database name (SID), username, password

SqlConnection con=new SqlConnection ("provider=msdaora.1; User Id=userid;data source=xf; Password=password ")

SQL Server does not need to install the client, so you must specify the server, and the database name

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 ");

Two functions and stored procedures in the package (Package) run in Oracle.

For example, to run one of the following SQL statements: "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 '% Xi lang 25% jelly% ';

1. In A. NET design (such as Design SqlDataAdapter), you cannot use the functions and stored procedures in a package directly, and if you want to use them, you can use the functions and stored procedures that you want to use in the package at design time, and then declare them again.

2. When you add code directly to the. NET runtime, the system directly seeks the contents of the package

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 '% Xi lang 25% jelly% ' ";

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. How to use stored procedures

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);






Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.