By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,733 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,733 IT Pros & Developers. It's quick & easy.

DBASE file connection problem :(

P: n/a
Hi all,

I wanted to connect an old DBASE file (I don't know the exact version) but I
could not make it at all. I couldn't find a way to execute sql statements on
db file using c#. The interesting thing my old client can connect to the
database and fetch data properly.

I tried all possibilities that I found on the web containing using ODBC
driver and importing the data into an access file and using this file
instead of working on the original file but I couldn't achieve these too.

I also used the all connections strings that connectionstrings.com suggests
but this didn't work too.

My data folder consists of a DBF, FPT and CDX file (afaik this file comes
only with the newer versions of DBASE). This may be helpful for you.

Any help will be appreciated.
Thanks in advance.
Apr 3 '07 #1
Share this Question
Share on Google+
6 Replies

P: n/a
Alenya,

The most important thing that you left out was the code that you are
using to access the file! Are you using the classes from the
System.Data.Odbc namespace? You mentioned an ODBC driver, and this is the
namespace that you would use to connect to data sources through ODBC
drivers.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Aleyna[]" <xo******@gmail.comwrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...
Hi all,

I wanted to connect an old DBASE file (I don't know the exact version) but
I could not make it at all. I couldn't find a way to execute sql
statements on db file using c#. The interesting thing my old client can
connect to the database and fetch data properly.

I tried all possibilities that I found on the web containing using ODBC
driver and importing the data into an access file and using this file
instead of working on the original file but I couldn't achieve these too.

I also used the all connections strings that connectionstrings.com
suggests but this didn't work too.

My data folder consists of a DBF, FPT and CDX file (afaik this file comes
only with the newer versions of DBASE). This may be helpful for you.

Any help will be appreciated.
Thanks in advance.

Apr 3 '07 #2

P: n/a
Thanks for reminding...

I used the following code:

string dbName = "dsn=lugat";

OdbcConnection odbcConn = new OdbcConnection(dbName);
try
{
odbcConn.Open();
//I write all tables into an XML file in order to ensure it works properly
or not
odbcConn.GetSchema(OdbcMetaDataCollectionNames.Tab les).WriteXml("TABLES.XML"); string cmdText = "Select * from LUGAT"; OdbcCommand cmd = new OdbcCommand(cmdText,odbcConn); OdbcDataReader reader = cmd.ExecuteReader();}catch (Exception e){ throw e;}finally{ odbcConn.Close();}and this is what the code writes to the TABLES.XML file<?xml version="1.0" standalone="yes"?><DocumentElement <Tables <TABLE_CAT>D:\LUGAT</TABLE_CAT <TABLE_NAME>LUGAT</TABLE_NAME <TABLE_TYPE>TABLE</TABLE_TYPE </Tables <Tables <TABLE_CAT>D:\LUGAT</TABLE_CAT <TABLE_NAME>LUGAT_SET</TABLE_NAME <TABLE_TYPE>TABLE</TABLE_TYPE </Tables></DocumentElement>However when I tried to access the db using the select statement it throwsan exception saying"Error [HY000][Microsoft][ODBC dBase Driver] External table is not in theexpected format."any ideas?"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>, haberiletisinde şunları yazdı:On**************@TK2MSFTNGP03.phx.gbl...Alen ya,> The most important thing that you left out was the code that you areusing to access the file! Are you using the classes from theSystem.Data.Odbc namespace? You mentioned an ODBC driver, and this is thenamespace that you would use to connect to data sources through ODBCdrivers.> Hope this helps.>>-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com>"Aleyna[]" <xo******@gmail.comwrote in messagenews:Oh**************@TK2MSFTNGP02.phx.gbl. ..>Hi all,>>>I wanted to connect an old DBASE file (I don't know the exact version)but I could not make it at all. I couldn't find a way to execute sqlstatements on db file using c#. The interesting thing my old client canconnect to the database and fetch data properly.>>>I tried all possibilities that I found on the web containing using ODBCdriver and importing the data into an access file and using this fileinstead of working on the original file but I couldn't achieve these too.>>>I also used the all connections strings that connectionstrings.comsuggests but this didn't work too.>>>My data folder consists of a DBF, FPT and CDX file (afaik this file comesonly with the newer versions of DBASE). This may be helpful for you.>>>Any help will be appreciated.>Thanks in advance.>>>>

Apr 3 '07 #3

P: n/a
A dbase file, not a forpro db file? what version?

maybe,you should translate it to forpro3.0 file first.(using vfp6)
Apr 4 '07 #4

P: n/a
A dBase file. I do not know the version but tried to connect using dBASE 3,4
and 5 drivers.

Now I found a tool to transfer the data into a mySQL db however still I
could not understand why I cannot connect and query properly whereas others
can make it.
"gshzheng" <gs******@gmail.com>, haber iletisinde şunları
yazdı:%2****************@TK2MSFTNGP04.phx.gbl...
>A dbase file, not a forpro db file? what version?

maybe,you should translate it to forpro3.0 file first.(using vfp6)



Apr 4 '07 #5

P: n/a


hi alena,
if u want to connect using SSIS means i can help.otherwise so sorry.

thx
sr*********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Feb 1 '08 #6

P: n/a
hi alenya,
if needed to connect using SSIS means i can help u. otherwise so sorry

thx
sreejith

*** Sent via Developersdex http://www.developersdex.com ***
Feb 1 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.