Can I use a DataTable as the Data Source in an OleDbConnection?

60 Views Asked by At

My goal is to take a datagridview and save it to a .dbf file. Actually, I want to overwrite the existing contents of the .dbf file.

I thought that perhaps I would need to convert the datagridview into a datatable to make the OleDbConnection happy, so I did. However, when the program hits .Open(), I get OleDbException: Invalid Path or File name.

Can I even use a datatable as the Data Source, or does it have to be an actual directory or file?

Source:

di.filename = Path.Combine(ClsGlobalVar.GWritePath, path2: $"{di.dbf_name.Trim()}.dbf");
FileInfo fi = new FileInfo(di.filename);

DataTable dt_save = dataGridView1.DataSource as DataTable;

using (OleDbConnection dbf_connection = new OleDbConnection($@"Provider=VFPOLEDB.1; Data Source={ dt_save }"))
{
    dbf_connection.Open();
0

There are 0 best solutions below