DBF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Klaus Kaiser Apolinário

    #1

    DBF

    Guys,
    I have a DBF ( :-S ) pseud-database here, and I need to access this dbf with
    C#, how I can make this???

    Klaus Kaiser Apolinário
    COL


  • Ignacio Machin

    #2
    Re: DBF

    Hi Klaus,

    I had a very hard time with some dbf from foxpro 2.5 ! , the thing is that
    you can read them without problem, either using OleDB or ODBC, the real
    problem is writting on them sometimes I got errors, at the end I did a mix
    solution, to some tables I write it from C# to others I create a prg file
    and use the fox.exe to execute the script :(

    Here is the code I'm using now, I use OleDB , so you need the vfpoledb.dll
    its come with any installation of VFP
    void ExecuteQuery( string DataSource, string Query)
    {
    string connString;
    OleDbConnection conn;
    OleDbCommand command;
    try
    {
    connString = "Provider=VFPOL EDB.1;Data Source="+ DataSource + ";";
    conn = new OleDbConnection ( connString);
    conn.Open();
    command = new OleDbCommand();
    command.Connect ion = conn;
    command.Command Text = Query;
    command.Execute NonQuery();
    conn.Close();
    }
    catch(Exception e)
    {
    }
    }

    This is how I read the table:
    void ReadTable( DataSet data, string sourceFile, string tablename)
    {
    try
    {
    string connString;
    OleDbConnection conn;
    OleDbDataAdapte r adapter;

    connString = "Provider=VFPOL EDB.1;Data Source="+ sourceFile + ";";
    conn = new OleDbConnection ( connString);
    conn.Open();
    adapter = new OleDbDataAdapte r( "select * from " +
    TableName(sourc eFile), conn);
    adapter.Fill( data, tablename);
    conn.Close();
    adapter = null;
    }
    catch(Exception e)
    {
    }

    }


    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Klaus Kaiser Apolinário" <klaus@curitiba online.com.br> wrote in message
    news:uOHpKK1hDH A.2164@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Guys,
    > I have a DBF ( :-S ) pseud-database here, and I need to access this dbf[/color]
    with[color=blue]
    > C#, how I can make this???
    >
    > Klaus Kaiser Apolinário
    > COL
    >
    >[/color]


    Comment

    Working...