DBASE file connection problem :(

  • Thread starter Thread starter Aleyna[]
  • Start date Start date
A

Aleyna[]

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.
 
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.
 
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.Tables).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]" <[email protected]>, haberiletisinde þunlarý yazdý:[email protected]...> Alenya,>> 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]> - (e-mail address removed)>> "Aleyna[]" <[email protected]> wrote in messageHi 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.>>>>
 
A dbase file, not a forpro db file? what version?

maybe,you should translate it to forpro3.0 file first.(using vfp6)
 
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.
 
hi alena,
if u want to connect using SSIS means i can help.otherwise so sorry.

thx
(e-mail address removed)
 
hi alenya,
if needed to connect using SSIS means i can help u. otherwise so sorry

thx
sreejith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top