0
votes

I'm creating a table in a dbase III (*.dbf) file. All works fine but some of the numeric columns need specific width and precision. If I add on the width and precision in the CREATE TABLE syntax, for example, HEIGHT NUMERIC(8,2) then it doesn't work. I have tried two connection strings...

CString connString = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + directory;
CString connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directory + ";Extended Properties=dBASE III;";

The first one will result in an error when I try to create the table and the second will allow me to create the table but there is no width or precision applied to the resulting dbf file.

The error for the odbc creat table statement is... Code = 80040e14 Code meaning = IDispatch error #3092 Source = Microsoft OLE DB Provider for ODBC Drivers Description = [Microsoft][ODBC dBase Driver] Syntax error in CREATE TABLE statement.

Anyone know what I should be using to create a dbf (dbaseIII) file that has specific field width and precision? Thanks.

1
I'm using a numeric type though, not a decimal. I am not able to change the table format at all, due to client legacy code. Thanks though.flobadob

1 Answers

0
votes

I´m late, sorry ;)

I think, you can´t. Look at this for ODBC Data Types

While dBASE allows a precision and a scale to be specified with a NUMERIC data type, it is not supported by the ODBC dBASE driver. The ODBC dBASE driver always returns a precision of 15 and a scale of 0 for a NUMERIC data type.