Hi!

Does anybody know the best way how to export a DataTable to a dBase 3 file?

Regards
Stephan

Re: Export Table to dBase 3 (.dbf) by Paul

Paul
Fri Sep 29 09:28:40 CDT 2006

On Fri, 29 Sep 2006 14:25:42 +0200, Stephan Zaubzer <stephan.zaubzer@schendl.at> wrote:

¤ Hi!
¤
¤ Does anybody know the best way how to export a DataTable to a dBase 3 file?
¤

What is the data source of the DataTable? Do you need to change any of the data or can it be
exported directly from the other data source (assuming there is one)?


Paul
~~~~
Microsoft MVP (Visual Basic)

Re: Export Table to dBase 3 (.dbf) by Stephan

Stephan
Fri Sep 29 10:49:25 CDT 2006

The data comes from a select statement which selects certain columns of
certain rows of a table.
Regards
Stephan

Paul Clement wrote:
> On Fri, 29 Sep 2006 14:25:42 +0200, Stephan Zaubzer <stephan.zaubzer@schendl.at> wrote:
>
> ¤ Hi!
> ¤
> ¤ Does anybody know the best way how to export a DataTable to a dBase 3 file?
> ¤
>
> What is the data source of the DataTable? Do you need to change any of the data or can it be
> exported directly from the other data source (assuming there is one)?
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)

Re: Export Table to dBase 3 (.dbf) by Thomas

Thomas
Sun Oct 01 10:48:36 CDT 2006

Hi Stephan

We have used the ODBC Driver to write dBase files. I think it was dBase IV =
or V. You have to try, if it works for you with dBase 3.

Here is an example code, we have used with .NET 2.0:

using System;
using System.Data;
using Microsoft.Data.Odbc;

public class DBaseConnector
{
private IDbConnection m_conn;

public DBaseConnector(string directory)
{
m_conn =3D OpenConnection(directory);
}

internal IDbConnection OpenConnection(string directoryName)=20
{
string connectionString =3D @"Provider=3DMSDASQL;Driver=3D{Microsof=
t dBase Driver (*.dbf)};DBQ=3D" + directoryName;
try=20
{
OdbcConnection conn =3D new OdbcConnection(connectionString);
conn.Open();
return conn;
}
catch (Exception)=20
{
// If you need your Exception handling, it goes here; if not
// forget about the try..catch statements.
throw;
}
}

public int Execute(string sql)=20
{
using(IDbCommand cmd =3D m_conn.CreateCommand())
{
cmd.CommandText =3D sql;
return cmd.ExecuteNonQuery();
}
}

public void Close()
{
m_conn.Close();
}
}

and you call from outside:

...
DBaseConnector connector =3D new DBaseConnector(m_destinationDir);
try
{
connector.Execute("INSERT INTO MyDbaseTable ...");
...
}
finally
{
connector.Close();
}


Greetings from Switzerland
Thomas

On Fri, 29 Sep 2006 17:49:25 +0200
Stephan Zaubzer <stephan.zaubzer@schendl.at> wrote:

> The data comes from a select statement which selects certain columns of=20
> certain rows of a table.
> Regards
> Stephan
>=20
> Paul Clement wrote:
> > On Fri, 29 Sep 2006 14:25:42 +0200, Stephan Zaubzer <stephan.zaubzer@sc=
hendl.at> wrote:
> >=20
> > =A4 Hi!
> > =A4=20
> > =A4 Does anybody know the best way how to export a DataTable to a dBase=
3 file?
> > =A4=20
> >=20
> > What is the data source of the DataTable? Do you need to change any of =
the data or can it be
> > exported directly from the other data source (assuming there is one)?
> >=20
> >=20
> > Paul
> > ~~~~
> > Microsoft MVP (Visual Basic)

Re: Export Table to dBase 3 (.dbf) by Paul

Paul
Mon Oct 02 08:04:45 CDT 2006

On Fri, 29 Sep 2006 17:49:25 +0200, Stephan Zaubzer <stephan.zaubzer@schendl.at> wrote:

¤ The data comes from a select statement which selects certain columns of
¤ certain rows of a table.
¤ Regards
¤ Stephan
¤

What kind of database are you selecting from?


Paul
~~~~
Microsoft MVP (Visual Basic)

Re: Export Table to dBase 3 (.dbf) by jools_h

jools_h
Mon Oct 02 10:36:55 CDT 2006

If the source data is from a SQL Server database then you could use DTS
to transform the data into your .dbf. Very powerful and very easy (
you can even select data as part of the transformation services)



Stephan Zaubzer wrote:
> Hi!
>
> Does anybody know the best way how to export a DataTable to a dBase 3 file?
>
> Regards
> Stephan