1
votes

I want to get a database schema (dBase), so I use "oledb" to get data from a dbase file for using getchemaTable to get the schema of data, but the "ColumnSize" of the numeric data type excludes "19". As the original data, such as "object_id" Type: nummeric column size: 12, but it returns the output to "19".

I want to show the results to the exact same. but.. I don't know what to do next.

public static DataSet getStructureDBF(string dir, string input)
    {
        OleDbConnection objConn = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=" +         dir + ";Persist Security Info=False;");
        objConn.Open();
        OleDbCommand objCmd = new OleDbCommand("Select * from " + input, objConn);

        OleDbDataReader objDataReader = objCmd.ExecuteReader();
        DataTable schemaTable = objDataReader.GetSchemaTable();
        DataSet dsnew = new DataSet();
        dsnew.Tables.Add(schemaTable);
        return dsnew;
    }
1
I don't know for sure but I suspect that one of those numbers is referring to the precision, i.e. the number of significant figures in the values, while one is referring to the size, i.e. the number of bytes the values occupy.jmcilhinney
I searched in Google and found the meaning that 19 is the default of ColumnSize.CLORets
In that case, I guess that suggests that all column types other than those for which you can explicitly set the size, e.g. varchar or the like, will have that size of 19. If that's the case, it seems a slightly odd choice.jmcilhinney
"19" has only numbers type but.. char(string) type no problem.CLORets
can you tell us also the EXACT numeric type (there are more than "numeric" in Foxpro DBF files)nabuchodonossor

1 Answers

1
votes

For all data types, dBASE field definitions store field length and precision. The latter is only relevant for numeric types, and the former is the maximum number width in digits, because that is how dBASE stores numbers: actual strings of digits.

See dbf file format specification

Edit

Note that data types Numeric and Float are stored as strings of digits. Number types in more recent versions of dBASE are stored as binary values.

Also see DBF reader implementation notes