SQLServer's data conversion service DTS call code

xiaoxiao2021-03-31  189

///

/// URL is the full path of the package, and the packagename is the package name; the method throws an exception; executing the structured file of DTS

/// /// Package /// Package /// < / returns> public static void ExceDTSPackage (string url, string packageName) {DTS.Package2Class package = new DTS.Package2Class (); try {Object MIA = System.Reflection.Missing.Value; package.LoadFromStorageFile (url, "", " "," ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Catch (Exception E) {throw new exception ("Exception" " URL " "failed:" E.Message);} finally {package.unitialize ()

}

///

/// DTS needs to be introduced to global variables, of course, if your original package does not have a global variable, it will not affect the correctness of the package execution. /// /// < PARAM Name = "URL"> /// /// /// public static void ExceDTSPackage (string url, string packageName, String bdzid_scmis, String bdzid_ztpj) {DTS.Package2Class package = new DTS.Package2Class (); try {Object MIA = System.Reflection.Missing.Value; package .LoadFromStorageFile (url, "", "", "", packageName, ref MIA); package.GlobalVariables.Item ( "bdzid_scmis"). let_Value (bdzid_scmis);. package.GlobalVariables.Item ( "bdzid_ztpj") let_Value (bdzid_ztpj ); Package.savetoRagefile (URL, ",", ", false); package.execute ();}

Catch (Exception E) {throw new exception ("Exception" " URL " "Failed:" E.MESSAGE);} finally {package.unInitialize ();

///

/// Execute the DTS package /// /// /// /// public static void excedtsssqlserver (String IP, String Userid, String PSWD, String PackageName) { DTS.Package2Class package = new DTS.Package2Class (); try {Object MIA = null; package.LoadFromSQLServer (ip, userid, pswd, DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", "", "", packagename, ref MIA); Package.execute ();} catch (Exception E)

{Throw new exception ("Execute Server" " " " " packagename "" "" E.MESSAGE);} finally {package.unInitialize ();}

}

///

/// DTS needs to pass the global variable /// /// /// < / param> /// /// /// // / public static void ExceDTSSqlServer (string ip, string userid, string pswd, string packagename, string bdzid_scmis, string bdzid_ztpj) {DTS.Package2Class package = new DTS.Package2Class (); try {Object MIA = null; package.LoadFromSQLServer (ip, userid, pswd, DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", "", "", packagename, ref MIA); package.GlobalVariables.Item. ( "bdzid_scmis") let_Value ( bdzid_scmis); package.GlobalVariables.Item ( "bdzid_ztpj") let_Value (bdzid_ztpj);. package.SaveToSQLServer (ip, userid, pswd, DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", "", "", ref MIA, false); Package.execute ();} catch new exception ("Perform server" " ip " "Pack" " packagename " "" " E.MESSAGE);} Fi Nally {package.uninitialize ();

}

转载请注明原文地址:https://www.9cbs.com/read-130768.html

New Post(0)