Stan
11/25/2002 4:07:00 AM
Hello,
I follow all your discussion and i try to connect to a dbf file like the
following steps:
* i have a file "c:\toto\mabd.dbf"
* i create a new project c# in .NET
* i create a button1 on the form
* i create a datagrid1 on the form
* here is my "Form1.cs"
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Data.Odbc;
namespace odbcessai
{
public class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
...
// Dispose
...
// Windows Form Designer generated code
...
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
OdbcConnection essc = new OdbcConnection(@"Driver={Microsoft
dBase Driver (*.dbf)};DBQ=c:\toto\");
OdbcDataAdapter essda = new OdbcDataAdapter("Select * from
MABD", essc);
DataSet essds = new DataSet();
essda.Fill(essds);
dataGrid1.DataSource = essds;
}
catch(System.IO.FileNotFoundException rerere)
{
MessageBox.Show("File not found");
}
}
}
I think that there is a syntax problem with the argument in dataadapter
creation. I don't know ?!
In result, if i run the application, and click on button1, an error occur
"FileNotFoundException" before my message"file not found" and debug stop at
the line under "Application.Run(new Form1());"
Try to do this, please and answer me the right corrections.
I you have any quetions... i'll be here, It's Important.
TIA