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