好吧,这可能看起来很愚蠢。但是,我不知道如何在 Visual Studio 2008 中的 C# 中进行“导入”。我知道 java,但不知道 C#。目前,我没有时间阅读 ac# book。所以,我需要一些帮助才能做到这一点。
我试图在这里使用代码 - SSIS Getting Execute Sql Task result set object
DataTable dt = new DataTable();
OleDbDataAdapter oleDa = new OleDbDataAdapter();
oleDa.Fill(dt, Dts.Variables["User::objShipment"].Value);
我收到错误消息 - 找不到类型或命名空间名称“OledDbDataAdapter”(您是否缺少 using 指令或程序集引用?)
我试图做一个java风格的导入。但它失败了。
using System.Data.OleDb::OleDbDataAdapter
下面给出的完整代码 -
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.OleDb;
namespace ST_LongCodeGoesHere.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
//To see the comment here, look at beyond end of this code.
public void Main()
{
// TODO: Add your code here
DataTable table = new DataTable();
OledDbDataAdapter oleDbA = new OleDbDataAdapter();
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
评论是——
/*
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
To open Help, press F1.
*/