我遇到了一个我正在重新利用并从中学习的代码问题,我希望社区可以帮助我。
这是完整的代码集;
我收到错误,抱怨“'对象'不包含'TextShown'的定义”。非常感谢任何有关正确声明格式的帮助。
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Data.OleDb;
using System.Text;
/// <summary>
/// This is the class to which to add your code. Do not change the name, attributes, or parent
/// of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
private OleDbConnection connection;
private OleDbCommand command;
private OleDbDataReader reader;
public object NumbersandTextBuffer { get; set; }
public override void PreExecute()
{
base.PreExecute();
connection = new OleDbConnection(Connections.DataSourceConnection.ConnectionString);
connection.Open();
command = new OleDbCommand();
command.Connection = connection;
// Build select query by iterating over the columns in first output collection
var query = new StringBuilder("SELECT ");
var outputCollection = ComponentMetaData.OutputCollection[0];
for (int i = 0; i < outputCollection.OutputColumnCollection.Count; i++)
{
query.AppendFormat(" [{0}]", outputCollection.OutputColumnCollection[i].Name);
if (i < outputCollection.OutputColumnCollection.Count - 1) query.Append(",");
}
query.AppendFormat(" FROM [{0}]", outputCollection.Name);
command.CommandText = query.ToString();
reader = command.ExecuteReader();
}
public override void PostExecute()
{
base.PostExecute();
command = null;
reader.Close();
connection.Close();
}
public override void CreateNewOutputRows()
{
while (reader.Read())
{
// Replace with own import code matching the name
// of the import buffer defined in the Script Transformation Editor
// and column names
NumbersandTextBuffer.AddRow();
NumbersandTextBuffer.TextShown = (string)reader["AgencyLongName"];
NumbersandTextBuffer.TextShown = (string)reader["AgencyShortName"];
NumbersandTextBuffer.TextShown = (string)reader["ProjectID"];
NumbersandTextBuffer.TextShown = (string)reader["CollectionRound"];
NumbersandTextBuffer.TextShown = (string)reader["Section"];
NumbersandTextBuffer.TextShown = (string)reader["TableType"];
NumbersandTextBuffer.TextShown = (string)reader["Metric"];
NumbersandTextBuffer.TextShown = (string)reader["Section1"];
NumbersandTextBuffer.TextShown = (string)reader["BenefitID"];
NumbersandTextBuffer.TextShown = (string)reader["RiskID"];
NumbersandTextBuffer.TextShown = (string)reader["Value"];
NumbersandTextBuffer.TextShown = (string)reader["F12"];
NumbersandTextBuffer.TextShown = (string)reader["F13"];
NumbersandTextBuffer.TextShown = (string)reader["F14"];
NumbersandTextBuffer.TextShown = (string)reader["F15"];
}
}
}