C# 操作DTS
来源:互联网 发布:负能量电影 知乎 编辑:程序博客网 时间:2024/06/11 20:06
in the C# class file for your project:
using System;using System.Runtime.InteropServices;using DTS;namespace DtsInterop{//This class loads and executes the DTS package.class ExecPkgWithEvents{/*Prior to running this code, create a DTS package and save it to SQL Server. Then set a reference to//the DTSPackage Object Library version 2.0 COM object.*/public Package2Class package;[MTAThread]static void Main(string[] args){ExecPkgWithEvents app = new ExecPkgWithEvents();app.Run();}public void Run(){try{package = new Package2Class();UCOMIConnectionPointContainer CnnctPtCont = (UCOMIConnectionPointContainer) package;UCOMIConnectionPoint CnnctPt;PackageEventsSink PES = new PackageEventsSink ();Guid guid = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5"); // UUID of PackageEvents InterfaceCnnctPtCont.FindConnectionPoint(ref guid, out CnnctPt);int iCookie;CnnctPt.Advise(PES, out iCookie);object pVarPersistStgOfHost = null;package.LoadFromSQLServer("PNXDEVBOX", null, null, DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, null,null, null, "Test", ref pVarPersistStgOfHost);package.Execute();package.UnInitialize();package = null;CnnctPt.Unadvise(iCookie); //a connection that is created by IConnectionPoint.Advise must be closed by calling IConnectionPoint.Unadvise to avoid a memory leak}catch(System.Runtime.InteropServices.COMException ex){Console.WriteLine("COMException {0}/n{1}/n{2}", ex.ErrorCode, ex.Message, ex.StackTrace);}catch(System.Exception ex){Console.WriteLine("Exception/n{0}/n{1}", ex.Message, ex.StackTrace);}}}//This class is responsible for handling DTS Package events. When an event is fired, a message is sent to//the console.class PackageEventsSink : DTS.PackageEvents{public void OnQueryCancel(string EventSource, ref bool pbCancel){Console.WriteLine("OnQueryCancel({0})", EventSource);pbCancel = false;}public void OnStart(string EventSource){Console.WriteLine("OnStart({0})", EventSource);}public void OnProgress(string EventSource, string ProgressDescription, int PercentComplete, int ProgressCountLow, int ProgressCountHigh){Console.WriteLine("OnProgress({0}, {1}, {2}, {3}, {4})", EventSource, ProgressDescription,PercentComplete, ProgressCountLow, ProgressCountHigh);}public void OnError(string EventSource, int ErrorCode, string Source, string Description, string HelpFile, int HelpContext, stringIDofInterfaceWithError, ref bool pbCancel){Console.WriteLine("OnError({0}, {1}, {2}, {3}, {4}, {5})", EventSource, ErrorCode, Source, Description,HelpFile, HelpContext);pbCancel = false;}public void OnFinish(string EventSource){Console.WriteLine("OnFinish({0})", EventSource);}}
- C# 操作DTS
- c#中调用DTS
- Delphi 操作 DTS
- Delphi 操作 DTS
- 在C#中应用DTS
- 在C#中应用DTS
- 在C#中应用DTS
- DTS
- DTS
- DTS
- dts
- dts
- dts
- DTS
- dts
- 使用VS.NET2003操作SQLServer DTS
- 使用VS.NET2003操作SQLServer DTS.
- C#中执行DTS的问题,请关注!
- 请教如何禁用网卡,Win2K/Win98
- 几个用CSS实现的网页Tabs的例子
- Java开发者必去的技术网站
- C#实现的根据年月日计算星期几的函数(专)
- 给年轻工程师的十大忠告!
- C# 操作DTS
- *控件*有横向和竖向的滚动条的DataGrid(横向支持从第几列滚动)
- CAD技术的革命性突破
- C#写木马程序
- 最近寝室管得严 得早点出来 省得费事 还得签名
- DataGrid中弹出日期控件
- 给c++程序员的一份礼物-常用工具集
- 出现ORA-12560问题的可能性以及相应的解决办法
- Asp.Net Forums中对.Net中序列化和反序列化的应用