Methods and notes for connecting Oracle9i to Asp.net

Source: Internet
Author: User
Tags oracleconnection

Recommended Methods

Public void oledboracle_dataset ()
{
String connectionstring = "Data Source = mine; user = sys; Password = sys;"; // write the connection string
Oracleconnection conn = new oracleconnection (connectionstring); // create a new connection
Oraclecommand cmd = new oraclecommand ("select * From fjdl. t_rights", Conn );
Dataset DS = new dataset ();
Oracledataadapter ODA = new oracledataadapter ();
ODA. selectcommand = cmd;
ODA. Fill (DS );
Conn. Close ();
Datagrid1.datasource = Ds. Tables [0]. defaultview;
Datagrid1.databind ();
}

The following are four methods for using dataset, datareader, oledb, and oralceclient:

Public void oledboracle_datareader ()
{
System. Data. oledb. oledbconnection oledb1 = new system. Data. oledb. oledbconnection ();
String sqltext = "select * from Scott. tadmin ";
System. Data. oledb. oledbdatareader reader;

Oledb1.connectionstring = "provider =/" oraoledb. oracle.1/"; user id = system; Password = system; Data Source = Rick ;";
System. Data. oledb. oledbcommand COM = new system. Data. oledb. oledbcommand (sqltext, oledb1 );

Com. Connection. open ();
Reader = com. executereader ();

Datagrid1.datasource = reader;
Datagrid1.databind ();

// This. response. Write (oledbconnection1.connectionstring );
Reader. Close ();
Com. Connection. Close ();
}
Public void oledboracle_dataset ()
{
System. data. oledb. oledbconnection oledb1 = new system. data. oledb. oledbconnection ("provider =/" oraoledb. oracle.1/"; user id = system; Password = system; Data Source = Rick ;");
String sqltext = "select * from Scott. tadmin ";
System. Data. dataset set1 = new dataset ();
System. Data. oledb. oledbdataadapter ada1 = new system. Data. oledb. oledbdataadapter (sqltext, oledb1 );
Ada1.fill (set1, "data1 ");

This. datagrid2.datasource = set1.tables ["data1"]. defaultview;
This. Maid ();
}
Public void oracle_dataset ()
{
System. Data. oracleclient. oracleconnection oracle1 = new system. Data. oracleclient. oracleconnection ("User ID = system; Data Source = Rick; Password = system ");
String sqltext = "select * from Scott. tadmin ";
System. Data. dataset set1 = new dataset ();
System. Data. oracleclient. oracledataadapter ada1 = new system. Data. oracleclient. oracledataadapter (sqltext, oracle1 );
Ada1.fill (set1, "oracle_data1 ");

This. datagrid3.datasource = set1.tables ["oracle_data1"]. defaultview;
This. datagrid3.databind ();
}
Public void oracle_datareader ()
{
System. Data. oracleclient. oracleconnection oracle2 = new system. Data. oracleclient. oracleconnection ();
String sqltext = "select * from Scott. tadmin ";
System. Data. oracleclient. oracledatareader reader;

Oracle2.connectionstring = "User ID = system; user id = system; Data Source = Rick; Password = system ";
System. Data. oracleclient. oraclecommand COM = new system. Data. oracleclient. oraclecommand (sqltext, oracle2 );

Com. Connection. open ();
Reader = com. executereader ();

Datagrid4.datasource = reader;
Datagrid4.databind ();

// This. response. Write (oledbconnection1.connectionstring );
Reader. Close ();
Com. Connection. Close ();
}

Note:

If the local network configuration of remote data is not set

ORA-00162: External dbid length 18 is greater than maximum (16)

The connection name cannot exceed 16 characters

Modification Method

Configuration and migration tools-> net configuration assistant Configuration

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.