OLE DB mode operations Oracle Database

Source: Internet
Author: User
Tags ole connectionstrings

OLE DB mode operations Oracle Database

A. Query statement:

using(OleDbConnection conn =NewOleDbConnection (system.configuration.configurationmanager.connectionstrings["LOCAL_ORCL"]. ConnectionString)) {Conn.                Open (); using(OleDbCommand cmd =Conn. CreateCommand ()) {Try{Cmd.commandtext="SELECT * from Hlb_his_requisition"; DataTable DT=NULL; OleDbDataAdapter adapter=NewOleDbDataAdapter (); Adapter. SelectCommand=cmd; DT=NewDataTable (); Adapter.                        Fill (DT); Cmd.                        Parameters.clear (); Datagridview1.datasource=DT; }                    Catch(Exception ee) {MessageBox.Show (EE. Message.tostring ()+"\ r \ n"+EE.                        Stacktrace.tostring ()); Cmd.                        Dispose (); Conn.                        Close (); Conn.                    Dispose (); }                }            }

Two. Insert statement:

 using (OleDbConnection conn =New OleDbConnection (system.configuration.configurationmanager.connectionstrings["Local_orcl"]. ConnectionString)) {Conn. Open ();using (OleDbCommand cmd = Conn. CreateCommand ()) { try {cmd. CommandText = "insert INTO Hlb_his_requisition (requisition_id, Patient_name, Patient_sex, patient_age, patient _bed, Charge_name, Sample_class, Requisition_state) VALUES (1, ' Zhang San ', 1, 1, 1, 1, 1, 1)"; Cmd. ExecuteNonQuery (); } catch (Exception ee) {MessageBox.Show (EE. Message.tostring () + "\ r \ n" + ee. Stacktrace.tostring ()); Cmd. Dispose (); Conn. Close (); Conn. Dispose (); } } }

Three. Connection string:

<add name="local_orcl" connectionstring="provider=oraoledb.oracle.1;d ATA source= (description= (address= (protocol=tcp) (host=192.168.31.11) (port=1521)) (Connect_data= (SERVICE_NAME=ORCL ))); User Id=scott; password=123; Unicode=true"/>


Four. is garbled:

Five. Whether to install the client:

OLE DB mode operations Oracle Database

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.