none
Error reading certain numeric values with VFPOLEDB driver

    Question

  • It appears that the VFPOLEDB driver tries to convert numeric types in VFP to decimal types in .NET.  In this case, it's a Numeric 9,3 in VFP and it's trying to put it into a decimal 8,3 in .NET.

    I know that VFP has this funny quirk where if you don't use all of the decimal places after the decimal point, it allows you to use extras in front of the decimal point.  In our case, the number is 104895.83 and yes, VFP is happy storing this in a Numeric 9,3 column.

    When trying to read this in .NET, you get this message:

    System.InvalidOperationException

    The provider could not determine the decimal value. blah, blah, blah...

    The question then is - is there a work-around?  I can find no way to force .NET to use greater precision.  About all I can come up with is to catch the exception and return a nice error message asking the user to make the column larger in VFP.

    Here's the .NET code, thanks in advance

    Mike

     

    string sqlString = "SELECT * FROM " + Path.GetFileName(dbfFullPath);

    OleDbConnection oleConn = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=" +

    folderName + ";Collating Sequence=MACHINE;");

    OleDbCommand oleCmd = new OleDbCommand(sqlString, oleConn);

    OleDbDataReader oleReader;

    try

    {

      oleConn.Open();

      oleReader = oleCmd.ExecuteReader();

    Tuesday, August 29, 2006 11:30 PM

Answers

  • Hi Cindy!

    Thanks for the response.  I have verified that I am using the latest drivers.

      Select Cast(FieldName As Decimal(3)) From TableName

    throws an exception "Function argument value, type or count is invalid" while

      Select Cast(FieldName As NUMERIC(11,3)) From TableName

    Works great!

    Thanks,

    Mike

    Tuesday, September 19, 2006 2:50 PM

All replies

  • Hi Mike,

    Be sure you have the latest FoxPro and Visual FoxPro OLE DB data provider, downloadable from msdn.microsoft.com/vfoxpro/downloads/updates .

    "Select Cast(FieldName As Decimal(3)) From TableName" works for me.

    Thursday, August 31, 2006 4:56 PM
  • Hi Cindy!

    Thanks for the response.  I have verified that I am using the latest drivers.

      Select Cast(FieldName As Decimal(3)) From TableName

    throws an exception "Function argument value, type or count is invalid" while

      Select Cast(FieldName As NUMERIC(11,3)) From TableName

    Works great!

    Thanks,

    Mike

    Tuesday, September 19, 2006 2:50 PM