Because the C # connection is a disconnected connection, the use of the database temporary table is reading that the data is not read, after a period of exploration, finally identifying the way: first fill the data into the DataTable, then use DataAdapter to use DataTable The data is uploaded to a temporary table, and the other SQL statement is performed under the premise of continuously open data connection.
The simple example is as follows:
private void Page_Load (object sender, System.EventArgs e) {if {DataTable myda = new DataTable () (this.IsPostBack!); DataColumn dcName = myda.Columns.Add ( "ID"); dcName.DataType = Type.GetType ("System.String"); DCNAME = myda.columns.add ("classid"); dcname.DataType = type.gettype ("system.string"); DCNAME = myda.columns.add ("mcLassid"); DCNAME .Dattype = type.gettype ("system.string"); DCNAME = myda.columns.add ("mclassname"); DCNAME.DATATYPE = type.gettype ("system.string"); this.viewState ["TABLE"] = myda;}} private void button2_click (object sender, system.eventargs e) {datatable myda = (dataable) this.viewState ["Table"]; DATAROW DR = myda.newrow (); dr [0] = this.id .Text; DR [1] = this.textBox3.text; DR [2] = this.mclassid.text; dr [3] = this.mclassname.text; myda.rows.add (tr); this.dataGrid1.datasource = MyDa; this.dataGrid1.database ();} private void button1_click (Object Sender, System.event Args e) {dataable ntable = (datatable) this.viewState ["Table"];
Mycn = new OracleConnection (STRCONN); mycn.open ();
MYCM = mycn.createCommand (); oracletransaction trans = mycn.begintransaction (); mycm.connection = mYcn; mycm.transaction = trans;
Try {OracleDataAdapter myadapter = new oracleDataAdapter (); oracletransaction trans = mycn.begintransaction ();
MyAdapter.InsertCommand = myCm; MyAdapter.InsertCommand.CommandText = "C_NAME_INN"; MyAdapter.InsertCommand.CommandType = CommandType.StoredProcedure; MyAdapter.InsertCommand.Connection = myCn; OracleParameter p2 = new OracleParameter ( "V_ID", OracleType.VarChar, 40) P2. SourceVersion = DATAROWVERSION.CURRENT; P2.SourceColumn = NTABLE.COLUMNS [0] .ColumnName; myadapter.insertcommand.parameters.Add (P2);
OracleParameter p1 = new OracleParameter ( "V_CLASSID", OracleType.VarChar, 40); p1.SourceVersion = DataRowVersion.Current; p1.SourceColumn = ntable.Columns [1] .ColumnName; MyAdapter.InsertCommand.Parameters.Add (p1);
OracleParameter p3 = new OracleParameter ( "V_MCLASSID", OracleType.VarChar, 40); p3.SourceVersion = DataRowVersion.Current; p3.SourceColumn = ntable.Columns [2] .ColumnName; MyAdapter.InsertCommand.Parameters.Add (p3);
OracleParameter p4 = new OracleParameter ( "V_MCLASSNAME", OracleType.VarChar, 40); p4.SourceVersion = DataRowVersion.Current; p4.SourceColumn = ntable.Columns [3] .ColumnName; MyAdapter.InsertCommand.Parameters.Add (p4);
Myadapter.Update (ntable);
myCm.Parameters.Clear (); myCm.CommandText = "ADD_CNAME"; myCm.CommandType = CommandType.StoredProcedure; myCm.ExecuteNonQuery (); myCm.CommandText = "C_NAME_DISPLAY"; myCm.CommandType = CommandType.StoredProcedure; OracleParameter [] pa = {new OracleParameter ( "returnInfo", OracleType.Cursor)}; pa [0] .Direction = ParameterDirection.Output; myCm.Parameters.Add (pa [0]); OracleDataReader ds = myCm.ExecuteReader (CommandBehavior.Default); THISDATAGRID1.DATASOURCE = DS; this.dataGrid1.database (); trans.commit ();} catch (oracleException er) {throw new exception;} finally {trans.dispose ();}} Example should be able to regenerate !!