I am trying to create a dbf table from a query to the database, made from a program written in C #.
I have followed the following thread: Create .DBF file from SQL table records
For this the project has included another one of these, called DbfLibrary. In an example reduced to my problem, I do the following:
static void Main(string[] args)
{
var fhaltaColumn = DbfFieldDescriptors.GetDateTimeField("fhalta");
var columns = new List<DbfFieldDescriptor>() {fhaltaColumn};
Func<MyClass, object> mapfhalta = myClass => myClass.fhalta;
var mapping = new List<Func<MyClass, object>>() { mapfhalta };
List<MyClass> values = new List<MyClass>();
values.Add(new MyClass()
{
fhalta = DateTime.Now
});
string fileName = "C:\\temp\\Archivo.dbf";
DbfFileFormat.Write(@fileName, values, mapping, columns, Encoding.Default);
}
public class MyClass
{
public DateTime fhalta { get; set; }
}
The result is a dbf file, with a field named fhalta, but the value is "/ /:: AM" and not DateTime.Now as I need.
How do I pass a datetime value correctly? What am I doing wrong?