vishal
vishal

Reputation: 616

How to set maxlength of column name while export to dbf file

I am exporting datatable to dbf file. If I have big column name, dbf file can export till first 10 characters.

Why it is like that?

using (var dBaseConnection = new OleDbConnection(
    @"Provider=Microsoft.Jet.OLEDB.4.0; " +
    @" Data Source=C:\Users\RobertWray\Documents\dBase; " +
    @"Extended Properties=dBase IV"))
{
    dBaseConnection.Open();

    string createTableSyntax = 
        "Create Table Person " +
        "(Name char(50), CustomerReference char(50), Phone char(20))";
    var cmd = new OleDbCommand(createTableSyntax, dBaseConnection);
    cmd.ExecuteNonQuery();
}

Is there any setting which I can do to export more length in column names.?

Upvotes: 1

Views: 1503

Answers (1)

Luaan
Luaan

Reputation: 63732

No.

DBF files have a limit on column length, and that limit is 10. If you abstract away all access to the files, you can do the mapping in a different layer (making the actual column names in the DBF just shortened IDs); if you simply write "SQL" directly, you're out of luck.

Why the limit is there? DBFs are old. Why are you using DBFs for anything today? Maybe there's a better embedded database for your usecase?

Upvotes: 3

Related Questions