SQL Server 2005 Oracle 10 gのC#ソースをインポート


データベース・オペレーションでは、あるデータベースから別のデータベースにデータをインポートする必要がある場合があります.ここでは、SQL Server 2005がOracle 10 gにインポートしたC#ソースプログラムについて説明します.
プログラムコードの参考は以下の通りです.
//--------------------------------------------------------------------  //AllRightsReserved,Copyright(C)2011,HairihanTECH,Ltd.  //--------------------------------------------------------------------  usingSystem.Data;  namespaceDotNet.Example  {  usingDotNet.BaseManager;  usingDotNet.DbUtilities;  publicclassImportExportData  {  ///<summary> ///      Oralce  ///</summary> publicvoidExport()  {  //this.ExportTable("Items_Area");  //this.ExportTable("Items_AuditStatus");  //this.ExportTable("Items_Degree");  //this.ExportTable("Items_Duty");  //this.ExportTable("Items_Education");  //this.ExportTable("Items_Express");  //this.ExportTable("Items_Links");  //this.ExportTable("Items_MembershipLevels");  //this.ExportTable("Items_Nationality");  //this.ExportTable("Items_NewsCategory");  //this.ExportTable("Items_OnSale");  //this.ExportTable("Items_OrganizeCategory");  //this.ExportTable("Items_Party");  //this.ExportTable("Items_Pattern");  //this.ExportTable("Items_PayCategory");  //this.ExportTable("Items_PostCategory");  //this.ExportTable("Items_RoleCategory");  //this.ExportTable("Items_SalaryItemCategory");  //this.ExportTable("Items_SendCategory");  //this.ExportTable("Items_Sex");  //this.ExportTable("Items_Title");  //this.ExportTable("Items_Units");  //this.ExportTable("Items_UserAuditStates");  //this.ExportTable("Items_Wed");  //this.ExportTable("Items_WorkCategory");  //this.ExportTable("Items_WorkFlowCategories");  //this.ExportTable("Items_WorkingProperty");  //this.ExportTable("Base_Businesscard");  //this.ExportTable("Base_Comment");  //this.ExportTable("Base_Contact");  //this.ExportTable("Base_ContactDetails");  //this.ExportTable("Base_Exception");  //this.ExportTable("Base_File");  //this.ExportTable("Base_Folder");  //this.ExportTable("Base_Items");  //this.ExportTable("Base_Log");  //this.ExportTable("Base_Message");  //this.ExportTable("Base_News");   //this.ExportTable("Base_Organize");  //this.ExportTable("Base_Module","SELECT*FROMBASE_MODULEORDERBYPARENTID,ID");  //this.ExportTable("Base_PermissionItem");  //this.ExportTable("Base_Role");  //this.ExportTable("Base_Staff");  //this.ExportTable("Base_Parameter");  //this.ExportTable("Base_Project");  //this.ExportTable("Base_Permission");  //this.ExportTable("Base_PermissionScope");  this.ExportTable("Base_Sequence");  //this.ExportTable("Base_StaffOrganize");  //this.ExportTable("Base_TableColumns");  //this.ExportTable("Base_User");  //this.ExportTable("Base_UserAddress");  //this.ExportTable("Base_UserOrganize");  //this.ExportTable("Base_UserRole");  //this.ExportTable("Base_StaffOrganize");  //this.ExportTable("Base_WorkFlowActivity");  //this.ExportTable("Base_WorkFlowCurrent");  //this.ExportTable("Base_WorkFlowHistory");  //this.ExportTable("Base_WorkFlowProcess");  System.Console.ReadLine();  }  publicvoidExportTable(stringtableName)  {  ExportTable(tableName,tableName);  }  ///<summary> ///       ///</summary> ///<paramnameparamname="tableName">  </param> ///<paramnameparamname="table">     </param> publicvoidExportTable(stringtableName,stringtable)  {  //         SqlHelpersqlHelper=newSqlHelper("DataSource=localhost;InitialCatalog=UserCenterV32;IntegratedSecurity=SSPI;");  sqlHelper.Open();  DataTabledataTable=newDataTable(tableName);  if(tableName.Equals(table))  {  dataTable=sqlHelper.Fill("SELECT*FROM"+table);  }  else  {  dataTable=sqlHelper.Fill(table);  }  sqlHelper.Close();  //         OracleHelperoracleHelper=newOracleHelper("DataSource=ORACLE11;user=DBO_USERCENTERV32;password=DBO_USERCENTERV32;");  oracleHelper.Open();  oracleHelper.BeginTransaction();  SQLBuildersqlBuilder=newSQLBuilder(oracleHelper);  try  {  //       oracleHelper.ExecuteNonQuery("TRUNCATETABLE"+tableName);  //         //oracleHelper.ExecuteNonQuery("createsequenceSEQ_"+tableName+"minvalue1maxvalue999999999999999999999999startwith1incrementby1cache20");  intr=0;  for(r=0;r<dataTable.Rows.Count;r++)  {  sqlBuilder.BeginInsert(tableName);  for(inti=0;i<dataTable.Columns.Count;i++)  {  sqlBuilder.SetValue(dataTable.Columns[i].ColumnName,dataTable.Rows[r][dataTable.Columns[i].ColumnName]);  }  sqlBuilder.EndInsert();  System.Console.WriteLine(" "+tableName+"    "+r.ToString()+" ");  }  System.Console.WriteLine("-- "+tableName+"   "+r.ToString()+" ");  oracleHelper.CommitTransaction();  }  catch(System.Exceptionexception)  {  oracleHelper.RollbackTransaction();  System.Console.WriteLine(tableName+"--"+exception.Message);  }  finally  {  oracleHelper.Close();  }  }  }

以上がSQL Server 2005がOracle 10 gに導入したC#ソースプログラムのすべてです.ここで紹介します.