Andile Choko

Andile Choko

  • NA
  • 53
  • 53.3k

Microsoft Jet database error

Oct 10 2011 4:45 PM
Hi...

I have a code that works well on my computer and some pc's but on other pc's it gives me the following exception:
Microsoft Jet Database engine could not find the object 'yahoo.csv' make sure the object exists and that you spell its name and path correctly.
Source Code:


FileInfo file = new System.IO.FileInfo(filename);string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source=\"" + file.DirectoryName +"\";Extended Properties='text;HDR=Yes;FMT=Delimited(,)';";OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConnectionString);OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(string.Format("SELECT * FROM [" + file.Name + "]", file.Name), conn);
conn.Open();
//some other code goes here and has no effect on the exception.
conn.Close();
I traced the code and i think the problem could be on the line i highlited above.




Updated Question

I think i have found something concerning the error;

when i trace my code, this is what i get from the line that contains "file.DirectoryName"  it says file.Directory= "C:\\Program Files\\Common Files\\Microsoft Shared\\DevServer\\10.0"

i discoverd that i only get this from computers that have been partioned, whereas computers  that haven't been partioned it gives me the correct file.DirectoryName.

 How do i then solve this error/Exception?


Answers (7)