Example of Oracle Database Connection, addition, deletion, modification, and query operations Code
1st Floor
Myconn = new system. Data. oledb. oledbconnection ("provider = msdaora.1; Data Source = oracle9; user id = test; Password = test ;")
2) Define and execute commands
Me. cmdinsert = new system. Data. oledb. oledbcommand ()
'Define and set the command attributes.
Me. cmdinsert. commandtext = "insert into table (name, old, Nation) values ('" & me. tname. text & "'," & "to_date ('" & me. told. text & "', 'dd/MM/yy')" & ",'" & me. tnation. text &"')"
Me. cmdinsert. commandtype = commandtype. Text
Me. cmdinsert. Connection = me. myconn
'Open the database connection
Me. myconn. open ()
'Call the executenonquery command to execute the INSERT command without return values.
Me. cmdinsert. executenonquery ()
Me. myconn. Close ()
2nd floor
(1) Connection
String strconn = "Data Source = source; user = sa; Password = sa ;";
Oracleconnection myconnection = new oracleconnection (strconn );
Myconnection. open ();
(2)
String strsel = "select * From table_name ";
Or strsel = "insert into table (ID, name) values ('1', '23 ')";
Or strsel = "delete from table where id = '1 '";
Oraclecommand mycom = new oraclecommand (strsel, myconnection );
Mycom. executenonreader ();
Myconnection. Close ();
Lanyahuhu (Sister Bao and sister lin, both of whom I like (calcium supplementation) on the third floor replied to-10-17 09:20:29 score 0 rows
26: String sconn = system. configuration. configurationsettings. deleettings ["dbconn"];
Row 27: m_conn = new oledbconnection (sconn );
Row 28: m_conn.open ();
The following error is reported:
Exception details: system. Data. oledb. oledbexception: Access denied.
the fourth floor of chinanewway (no trace of the new road) replied to 09:32:55 score 0 I know, or your database is not a trusted connection, you must enter
user ID and password to access the database, or your Oracle Database Service is not started.
Chinanewway on the fifth floor (no trace of the new road) replied to 09:37:27 score 0 in the web. config file can be added with the following key values:
<Deleetask>
<Add key = "oledbconnection. connectionstring "value =" packet size = 4096; user id = Lamis; Password = Lamis; Data Source = & quot; LAMIS-SERVER & quot; provider = sqloledb; persist Security info = false; initial catalog = Lamis; workstation id = sosore "/>
<Add key = "strconnection" value = "Data Source = LAMIS-SERVER; initial catalog = Lamis; persist Security info = false; user id = Lamis; Password = Lamis; workstation id = cxq; packet size = 4096 "type =" codeph "text ="/codeph "/>
</Appsettings>