As CHill60 has indicated, you are missing the commit. But you have also not taken advantage of the using statement. In the following, I give the template that I think your method should take.
private void button1_Click ( object sender,
EventArgs e )
{
DataSet data_set = new DataSet ( );
DataTable data_table = new DataTable ( );
string insert_statement = String.Empty;
using ( OleDbConnection ole_db_connection =
new OleDbConnection ( ) )
{
OleDbDataAdapter ole_db_data_adapter;
OleDbCommand ole_db_command ;
ole_db_connection.ConnectionString =
"Data Source=XE; " +
"User ID=ER; " +
"Password=ER; " +
"Provider=msdaora";
ole_db_connection.Open ( );
ole_db_command = new OleDbCommand ( );
ole_db_command.Connection = ole_db_connection;
ole_db_command.CommandText =
"select * from bill where BILL_NO = '" +
comboBox1.SelectedValue.ToString ( ) +
"' ";
ole_db_command.CommandType = CommandType.Text;
ole_db_data_adapter = new OleDbDataAdapter (
ole_db_command );
ole_db_data_adapter.Fill ( data_set );
}
data_table = data_set.Tables [ 0 ];
insert_statement = "INSERT INTO BILL2 ( " +
"BILL_NO, " +
"CUSTOMER__NAME, " +
"ITEM_TAKEN, " +
"PRICE, " +
"MODE_OF_PAYMENT, " +
"TOTAL, " +
"DATE_PUR, " +
"SALE_FROM ) " +
"VALUES ( " +
":BILL_NO, " +
":CUSTOMER__NAME, " +
":ITEM_TAKEN, " +
":PRICE, " +
":MODE_OF_PAYMENT, " +
":TOTAL, " +
":DATE_PUR, " +
":SALE_FROM )";
using ( OracleConnection oracle_connection =
new OracleConnection ( ) )
{
OracleDataAdapter oracle_adapter;
OracleTransaction oracle_transaction;
oracle_connection.ConnectionString =
"Data Source=XE; " +
"Persist Security Info=True; " +
"User ID=ER; " +
"Password=ER; " +
"Unicode=True" );
oracle_connection.Open ( );
oracle_transaction =
oracle_connection.BeginTransaction ( );
oracle_adapter = new OracleDataAdapter ( );
oracle_adapter.InsertCommand =
new OracleCommand ( insert_statement,
oracle_connection);
foreach ( DataRow data_row in data_table.Rows )
{
oracle_adapter.InsertCommand.Parameters.Add (
new OracleParameter (
":BILL_NO",
data_row [ "BILL_NO" ] ) );
oracle_adapter.InsertCommand.Transaction =
oracle_transaction;
oracle_adapter.InsertCommand.ExecuteNonQuery ( );
}
oracle_transaction.Commit ( );
}
MessageBox.Show ( "DONE" );
}
}
Note that the ole_db_connection in the first using need not be closed. And by adding a second using for oracle_connection, there is no need to close it. Just before the end of the oracle_connection using, the oracle_transaction Commit occurs.
Hope that helps.