tags:

views:

329

answers:

3

I have huge problem:

I have lots of .dbf files(~50000) and I need to import them into Oracle database. I open conncection like this:

     OleDbConnection oConn = new OleDbConnection();
  OleDbCommand oCmd = new OleDbCommand();
  oConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directory + ";Extended Properties=dBASE IV;User ID=Admin;Password=";
            oCmd.Connection = oConn;
            oCmd.CommandText = @"SELECT * FROM " + tablename;
        try
            {
                oConn.Open();
                resultTable.Load(oCmd.ExecuteReader());
            }
            catch (Exception ex)
            {
                 MessageBox.Show(ex.Message);
              }
oConn.Close();
oCmd.Dispose();
oConn.Dispose();

I read them in loop, and then insert into oracle. Everything's fine. BUT: There is about 1000 files, that I can't open. They raise exception "not a table". So I google, and install Borland Database Engine. Now everything wokrs fine....but no.

Now, when I'm reading files, on 1024 file exception raises: "System resource exceeded". But I have lots of free resources. When I remove BDE, everything's fine again, no "system resource exceeded" error, but I cant read all files.

Help please.

PS: Tried using ODBC but nothing changes.

A: 

I notice that you are using Jet oledb provider to connect to your dbf files ,I'm not sure if this will solve your problem or not but there is an oledb provider for visual FoxPro that I think you can use to connect to dbf files.

Beatles1692
Same problem with OleDb VFP - "not a table".
Drabuna
A: 

Various flavors of DBF (dBASE, Clipper, FoxPro) are similar, with one notable exception: DBF7, which was introduced with Visual dBASE 7, and powered by BDE. DBF Viewer 2000 claims to support DB7, probably natively since the format still isn't that complicated. Maybe there are some file properties/info that you can view to confirm that all the "not a table" DBFs are DBF7.

Even if that turns out to define the nature of the problem, I don't see a particularly straightforward solution. If this is a one-time deal, maybe you can run the loop, save the names of the "1000" files that don't work without the BDE installed, and do a second pass with the BDE. (If it's more than 1024, you'd need a third pass.)

Ken
A: 

I have a Python module which can extract data from most DBF files, including DBF7, whose structure is somewhat different. It doesn't need drivers, OleDb or ODBC -- it just reads the file. It checks input files very carefully, and gives much more detailed messages than "not a table" if it is not happy. Can you make a few sample files available for inspection?

John Machin