use this for gtt ON COMMIT PRESERVE ROWS
Temp_Hierarchy is my GTT with "ON COMMIT PRESERVE ROWS"
MyCommand.CommandText = "INSERT INTO TEMP_HIERARCHY …." //this can be a call to a stored procedure which fills the data into the temporary table
MyConnection = MyDB.CreateConnection();
DbDataAdapter MyAdapter = MyDB.GetDataAdapter();
MyConnection.Open();
MyCommand.Connection = MyConnection;
MyTransaction = MyConnection.BeginTransaction();
MyCommand.Transaction = MyTransaction;
RecordInserted = MyCommand.ExecuteNonQuery();
MyCOmmand.CommandText = "SELECT * FROM TEMP_HIERARCHY ….";
MyAdapter.SelectCommand = MyCommand;
MyDataSet = new DataSet();
MyAdapter.Fill(MyDataSet);
MyTransaction.Commit();