Hello,

i have to write a homework for my university (deadline is tonight...) and this OleDbConnection is making me mad.
I want to load a .csv-File into a Dataset and then fill the DataGridView with the DataSet, but I dont get it to work! The Code is okay but there is always a runtime error when I try to load the File.

I am sorry, my error is in german, but I will try to translate it:

"System.Data.OleDb.OleDbException (0x80004005): 'C:\csvFilesFolder\test.csv' ist kein zulässiger Pfad. Stellen Sie sicher, dass der Pfad richtig eingegeben wurde und dass sie mit dem Server, auf dem sich die Datei befindet, verbunden sind."

--->
"System.Data.OleDb.OleDbException (0x80004005): 'C:\csvFilesFolder\test.csv' is no correct pathname. Please make sure if the path is correctly spelled and that you are connected to the server, on which the file is saved." (followed by 8 more error-rows)

I have a button that loads the path in a textbox and uploads the file into my dataset.
I do not use the variable "txtFileName" yet, for I want to make it work in a static way first - so dont be confused.

What am I doing wrong?? Please help me asap...

Here is my source code:


private: System::Void btn_load_Click(System::Object^ sender, System::EventArgs^ e) {


Stream^ loadStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "C:\\";
openFileDialog1->Filter = "CSV Files (*.csv)|*.csv|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 1;
openFileDialog1->FileName = txtFileName->Text;
openFileDialog1->RestoreDirectory = true;


if ( openFileDialog1->ShowDialog() == System::Windows::Forms:ialogResult::OK )
{
if ( (loadStream = openFileDialog1->OpenFile()) != nullptr )
{
txtFileName->Text = openFileDialog1->FileName;
Import();
loadStream->Close();

this->dgv_cursos->DataSource = this->ds->Tables;
this->Show();

}

}

}




private: void Import()
{
try
{
String^ selectCommand = "select * from test.csv";
this->connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\csvFilesFolder\\test.csv;Extended Properties=\'text;HDR=Yes;FMT=Delimited\'";
this->oledbConn = (gcnew System:ata::OleDb::OleDbConnection(this->connString));
this->oledbDA = (gcnew System:ata::OleDb::OleDbDataAdapter(selectCommand, oledbConn));
this->oledbConn->Open();
this->ds = (gcnew System:ata:ataSet());
this->oledbDA->Fill(ds);

}

catch (System::Exception ^exp)
{
MessageBox::Show(exp->ToString(), "Error");
return;

}

finally
{
this->oledbConn->Close();

}

}