HighTechTalks DotNet Forums  

Reading FoxPro Date field frpm ODBC

Dotnet Framework (ODBC.net) microsoft.public.dotnet.framework.odbcnet


Discuss Reading FoxPro Date field frpm ODBC in the Dotnet Framework (ODBC.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Enzo
 
Posts: n/a

Default Reading FoxPro Date field frpm ODBC - 07-02-2004 , 12:29 AM






Ok, what is the trick!!!

I am using C# to read a FoxPro DBF file.

I do the following:

Private DataSet getDBFData(string dbfFile)
{
DataSet ds = new DataSet();
string Sql;
int dbfNameStart = dbfFile.LastIndexOf(@"\");
string dbfTableName = dbfFile.Substring(dbfNameStart + 1);
//Define a connection string with file path as parameter
string Connection = "Provider=MSDASQL/SQLServer ODBC;Driver={Microsoft Visual FoxPro Driver};" +
@"SourceType=DBF;SourceDB=D:\DA197\OfficeDepot\Cle aned Data;" +
"InternetTimeout=300000;Transact Updates=True";

//This simple query is all u need to extract data. Make sure you specify filename
//with extension
Sql = "select * from " + dbfTableName;
OdbcDataAdapter OdbcConn = new OdbcDataAdapter(Sql, Connection);
OdbcConn.Fill(ds);
OdbcConn.Dispose();

return ds;
}

The problem is that the file has a date field and it is return like this: 36459.704756944

First of all, why does the driver return it like this and not a normal date, and second, how do I fix this problem???

Reply With Quote
  #2  
Old   
Paul Clement
 
Posts: n/a

Default Re: Reading FoxPro Date field frpm ODBC - 07-06-2004 , 03:46 PM






On Thu, 1 Jul 2004 21:29:01 -0700, "Enzo" <enzomaini (AT) dotnetfan (DOT) net> wrote:

¤ Ok, what is the trick!!!
¤
¤ I am using C# to read a FoxPro DBF file.
¤
¤ I do the following:
¤
¤ Private DataSet getDBFData(string dbfFile)
¤ {
¤ DataSet ds = new DataSet();
¤ string Sql;
¤ int dbfNameStart = dbfFile.LastIndexOf(@"\");
¤ string dbfTableName = dbfFile.Substring(dbfNameStart + 1);
¤ //Define a connection string with file path as parameter
¤ string Connection = "Provider=MSDASQL/SQLServer ODBC;Driver={Microsoft Visual FoxPro Driver};" +
¤ @"SourceType=DBF;SourceDB=D:\DA197\OfficeDepot\Cle aned Data;" +
¤ "InternetTimeout=300000;Transact Updates=True";
¤
¤ //This simple query is all u need to extract data. Make sure you specify filename
¤ //with extension
¤ Sql = "select * from " + dbfTableName;
¤ OdbcDataAdapter OdbcConn = new OdbcDataAdapter(Sql, Connection);
¤ OdbcConn.Fill(ds);
¤ OdbcConn.Dispose();
¤
¤ return ds;
¤ }
¤
¤ The problem is that the file has a date field and it is return like this: 36459.704756944
¤
¤ First of all, why does the driver return it like this and not a normal date, and second, how do I fix this problem???

Yeah, that looks rather bizarre. Have you tried using the OLEDB provider?

http://www.microsoft.com/downloads/d...displaylang=en
http://www.able-consulting.com/MDAC/...orVisualFoxPro


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.