ThinkGeo.com    |     Documentation    |     Premium Support

DbfColumn in ShapeFileFeatureLayer

I create a ShapeFileFeatureLayer with a list of DbfColumn
One of the DbfColumn is type Date
col = new DbfColumn(“date”, DbfColumnType.Date, 8, 0);
And one with type Logical
col = new DbfColumn(“valid”, DbfColumnType.Logical, 1, 0);

I try to update a value in a feature

f.ColumnValues.Add(“date”,???); What about the DateTime.Now ???
And
f.ColumnValues.Add(“valid”,???); Is it “True”, “1”, …

Thanks
Regards
Laurent M

Hi Laurent M,

The DbfColumnType.Date format is YYYYMMDD(for example 20160326) and the size of DbfColumnType.Logical is 1 byte, the default value is “?”. “Y” or “y”( Yes), “N” or “n”( No), “F” or “f” (False), “T” or “t”(True).

The code are as follows:

// Date in format - YYYYMMDD
shapeFileFeatureSource.UpdateDbfData(features[0].ColumnValues[“id”], “date”, DateTime.Now.Date.ToString(“yyyyMMdd”));
// ? - Default
// Y,y - Yes
// N,n - No
// F,f - False
// T,t - True
shapeFileFeatureSource.UpdateDbfData(features[0].ColumnValues[“id”], “valid”, “T”);

Hope it’s helped.

Thanks,
Peter

Ok Thanks

And for
DbfColumn(“date”, DbfColumnType.DateTime, ??, 0);
DateTime format is 20160404nnnnnn

Best regards
Laurent M

Hi Laurent M,

Please try the following code.

   shapeFileFeatureSource.AddColumn(new DbfColumn("dateTime", DbfColumnType.DateTime, 14, 0));

   // Chronological data consisting of month, day, year, hours, minutes, and seconds
   shapeFileFeatureSource.UpdateDbfData(features[0].ColumnValues["id"], "dateTime", string.Format("{0:MMddyyyyHHmmss}", DateTime.Now)); 

Thanks,
Peter