Hi,
please help.
I am getting the following trying to load shape "The record is invalid, please call Validate method to check the failed reason.Record index: 1".
Some background - there are shapefiles containing information for projects. I need to create new shapefiles for each project. The shape files are created and there are no error or exceptions, but as soon as I try to load the shapefile I get the above error. Any information will be greatly appreciated. Below is the Code used to create and load the shape file.
Create
var
sortedDic = (from entry in dicVals orderby entry.Key ascending select entry);foreach (KeyValuePair<string, string> kvp in sortedDic)string sProjectID = kvp.Key;string sProjextIDFld = kvp.Value;if (!sPath.EndsWith("\\"))"\\";".shp";switch (sType)case "Point":case "Multipoint":ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Multipoint, sPath, nulldbf); break;case "Line":case "Multiline":ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polyline, sPath, nulldbf);break;case "Polygon":case "Multipolygon":ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, sPath, nulldbf);break;ShapeFileFeatureLayer.BuildIndexFile(sPath);ShapeFileFeatureLayer sl = new ShapeFileFeatureLayer(sPath, ShapeFileReadWriteMode.ReadWrite);foreach (Feature feature in shapeLayer.QueryTools.GetFeaturesByColumnValue(sProjextIDFld, sProjectID, ReturningColumnsType.NoColumns))TransactionResult result = sl.EditTools.CommitTransaction();"Features added to " + sPath + " = " + result.TransactionResultStatus.ToString());
Load
string
sPath +=
sPath += id +
sPath = MapPath("~/futureprojects");string id = "3";if (!sPath.EndsWith("\\"))"\\";".shp";try
{
Map1.EditOverlay.FeatureSource.Open();
sl.Open();
sl.Validate();
Map1.EditOverlay.EditTools.BeginTransaction();
{
Map1.EditOverlay.EditTools.Add(f);
}
sl.Close();
}
{
}
ShapeFileFeatureLayer.BuildIndexFile(sPath);ShapeFileFeatureLayer sl = new ShapeFileFeatureLayer(sPath, ShapeFileReadWriteMode.ReadOnly);foreach (Feature f in sl.QueryTools.GetAllFeatures(ReturningColumnsType.NoColumns))TransactionResult result = Map1.EditOverlay.EditTools.CommitTransaction();catch (Exception ex)throw new Exception(ex.Message);
Thanks
Govin
{
sPath +=
sPath += id.ToString() +
{
;
}
sl.Open();
sl.EditTools.BeginTransaction();
{
sl.EditTools.Add(feature);
}
Response.Write(
sl.Validate();
sl.Close();
id++;
}
shapeLayer.Close();