I have a datatable which has the following structure
DataColumn sourceTblCol = new DataColumn("SourceTableName", typeof(System.Data.SqlTypes.SqlString));
importXMLMainDt.Columns.Add(sourceTblCol);
DataColumn ordinalPosCol = new DataColumn("OrdinalPosition", typeof(System.Data.SqlTypes.SqlInt32));
importXMLMainDt.Columns.Add(ordinalPosCol);
DataColumn grpNameCol = new DataColumn("GroupName", typeof(System.Data.SqlTypes.SqlString));
importXMLMainDt.Columns.Add(grpNameCol);
DataColumn entityTypeIDCol = new DataColumn("EntityTypeID", typeof(System.Data.SqlTypes.SqlInt32));
importXMLMainDt.Columns.Add(entityTypeIDCol);
DataColumn entityNameCol = new DataColumn("EntityName", typeof(System.Data.SqlTypes.SqlString));
importXMLMainDt.Columns.Add(entityNameCol);
DataColumn exportXMLCol = new DataColumn("ExportData", typeof(System.Data.SqlTypes.SqlXml));
importXMLMainDt.Columns.Add(exportXMLCol);
I am looping through all the xml files in a directory and adding that XML content as sqlXML in the datatable
xmlFiles = Directory.GetFiles(this.WrkImportFilePath, "*.xml");
foreach (string filename in xmlFiles)
{
using (XmlReader xmlReaderObj = XmlReader.Create(filename))
{
while (xmlReaderObj.Read())
{
sqlxmlObj = new SqlXml(xmlReaderObj);
}
xmlReaderObj.Close();
}
importXMLMainDt.Rows.Add(srcTableName, ordinalPos, grpName, entityTypeID, string.Empty, sqlxmlObj);
sqlxmlObj = null;
}
}
It is working fine for 2500 XML files but throwing exception if the number of file goes more that 3000.The max number of files can be upto 12,000. I need to create this datatable and pass it as table valued parameter in stored procedure.So how do I handle this problem?