Click here to Skip to main content
15,910,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If file name has additional dot character like below:

sample.data.csv next select statement:

SELECT * FROM [sample.data.csv]
with connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Data\"; Extended Properties="text;HDR=Yes;Format=Delimited;";
Getting below exception:

The Microsoft Jet database engine could not find the object 'sample'

What I have tried:

If file name has additional dot character like below:

sample.data.csv next select statement:

SELECT * FROM [sample.data.csv]
with connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Data\"; Extended Properties="text;HDR=Yes;Format=Delimited;";
Getting below exception:

The Microsoft Jet database engine could not find the object 'sample'
Posted
Updated 24-Apr-17 23:55pm

See the documentation: Table Name Limitations | Microsoft Docs[^]
Quote:
Table names can contain any valid characters (for example, spaces). If table names contain any characters except letters, numbers, and underscores, the name must be delimited by enclosing it in back quotes (`).

So try:
SQL
SELECT * FROM `sample.data.csv`
 
Share this answer
 
Comments
ManojRGEC 25-Apr-17 6:57am    
Thanks for the answer, but it is not working for me. I am getting same error i.e. "The Microsoft Jet database engine could not find the object 'sample.data'. Make sure the object exists and that you spell its name and the path name correctly."
Richard MacCutchan 25-Apr-17 8:51am    
Text/csv are treated differently by OLEDB, see my comments below.
 
Share this answer
 
Comments
ManojRGEC 25-Apr-17 7:05am    
My file name contains a additional dot (.) as given below. I am using Oledb connection string given below.
public const string ConnectionStringTemplateJet = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=dBase IV;";


Getting error at ExecuteReader() method

_dbConnection = new OleDbConnection(connectionString);
_dbConnection.Open();
_dbCommand = new OleDbCommand(selectString, _dbConnection);
_dbReader = _dbCommand.ExecuteReader();
Richard MacCutchan 25-Apr-17 8:46am    
That is not the correct way to do it. Follow the link I gave you and see how to get the proper table name from the driver.
Richard MacCutchan 25-Apr-17 8:50am    
When the file is imported it will replace the dots with # characters to make the table name. So your table name will be sample#data#csv.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900