We have an SSIS package, in which we load data into an Excel spreadsheet. The Excel columns need to have names with special characters, such as ".", "::" - ex: [ColumnA.property1], [ColumnB::property2.extension2].
When we try to run the SSIS package, we get an error (Invalid bracketing) as we cannot process the data to spreadsheet columns with names containing these special characters.
Is there a way to accommodate ths? We were told that these column names have to be as stipulated, but because there is so much data to process (frequently), we cannot perform this manually.
The code which loops through the columns (written in C#) is:
foreach (DataRow dt_row in dt.Rows)
{
string SchemaName = "";
string TableName = "";
object[] array = dt_row.ItemArray;
SchemaName = array[0].ToString();
TableName = array[1].ToString();
//Load Data into DataTable from SQL ServerTable
// Assumes that connection is a valid SqlConnection object.
string queryString =
"SELECT * from " + SchemaName + "." + TableName;
SqlDataAdapter adapter = new SqlDataAdapter(queryString, myADONETConnection);
DataSet ds = new DataSet();
adapter.Fill(ds);
//Get Header Columns
string TableColumns = "";
// Get the Column List from Data Table so can create Excel Sheet with Header
foreach (DataTable table in ds.Tables)
{
foreach (DataColumn column in table.Columns)
{
TableColumns += column + "],[";
}
}
and the error received is:
System.Data.OleDb.OleDbException (0x80040E14): Invalid bracketing of name '[ColumnA.property1]'. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ST_f776e39f704d46f98e2ddf46ae7ec8dd.ScriptMain.Main()
User contributions licensed under CC BY-SA 3.0