TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Murali krishna Ande
NA
57
51.7k
got the error "Cannot have more than 32 columns" while creating datarelation b/w datacolumns.....?????
Jun 8 2011 1:56 AM
Hi,
I am comparing to datatables and returning differences with another datatable...
But I got the error while creating the data relation i.e., "Cannot have more than 32 Columns" which is in red color.
private DataTable GetDifferences(DataTable dbTable, DataTable xlTable)
{
DataTable resultTable = new DataTable();
using (DataSet ds = new DataSet())
{
ds.Tables.AddRange(new DataTable[] { dbTable.Copy(), xlTable.Copy() });
DataColumn[] dbTableColumns = new DataColumn[ds.Tables[0].Columns.Count];
for (int i = 0; i < dbTableColumns.Length; i++)
{
dbTableColumns[i] = ds.Tables[0].Columns[i];
}
DataColumn[] xlTableColumns = new DataColumn[ds.Tables[1].Columns.Count];
for (int i = 0; i < xlTableColumns.Length; i++)
{
xlTableColumns[i] = ds.Tables[1].Columns[i];
}
DataRelation dr1 = new DataRelation(string.Empty, dbTableColumns, xlTableColumns, false);
ds.Relations.Add(dr1);
DataRelation dr2 = new DataRelation(string.Empty, xlTableColumns, dbTableColumns, false);
ds.Relations.Add(dr2);
for (int i = 0; i < dbTable.Columns.Count; i++)
{
resultTable.Columns.Add(dbTable.Columns[i].ColumnName, dbTable.Columns[i].DataType);
}
resultTable.BeginLoadData();
foreach (DataRow parentRow in ds.Tables[0].Rows)
{
DataRow[] childRows = parentRow.GetChildRows(dr1);
if (childRows == null || childRows.Length == 0)
resultTable.LoadDataRow(parentRow.ItemArray, true);
}
foreach (DataRow parentRow in ds.Tables[1].Rows)
{
DataRow[] childRows = parentRow.GetChildRows(dr2);
if (childRows == null || childRows.Length == 0)
resultTable.LoadDataRow(parentRow.ItemArray, true);
}
resultTable.EndLoadData();
}
return resultTable;
}
can some body plz tell me how can we sort out this issue..??
Thanks
Murali krishna.
Reply
Answers (
2
)
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
How can I check a new line and space characters