Microsoft Text Driver for ODBC - Error while trying to retrieve information from the csv file

I have a ODBC wrapper class in my application which opens a connection using DSN username & password (user supplies this in the startup of application). Internally the application calls OpenConnection method to connect to dsn.
Ideally this works for most of the databases. However now i want to use a comma seperated file as a database. I created an ODBC using microsoft text driver. I try to give this DSN details to my application (essentially only the user name) although i don't get any error while connecting. I get the following error when my application executes a select statement (select * from table_name order by email_address):

[Microsoft][ODBC Text Driver] The Microsoft Jet database engine cannot open the file '(unknown)'.  It is already opened exclusively by another user, or you need permission to view its data.'

Who is Participating?
AxterConnect With a Mentor Commented:
Have you tried using it without the userID and password?
Hi picasothakkar,
Please show us the conection string you're using.

David Maisonave :-)
picasothakkarAuthor Commented:
the application is using the following method to establish the connection

odbc::Connection *
            string                  &sErrMsg
      sErrMsg = "";

      LogFA(getLogID(), LOG_INFO,
            "OdbcDirectory::OpenOdbcConnection(): dsn='%s', userid='%s'",
                  this->m_dsn.c_str(), this->m_userId.c_str());

      try {
            this->m_pSession = DriverManager::getConnection(this->m_dsn,
                                                                  this->m_userId, this->m_password);
            return this->m_pSession;
      catch(SQLException& e) {
            sErrMsg = "ODBC connection failed: " + e.getMessage();

            LogFA(getLogID(), LOG_FATAL,
                  "OdbcDirectory::OpenOdbcConnection(): %s", sErrMsg.c_str());

            return NULL;
Do you have the latest Microsoft Jet database engine installed?
picasothakkarAuthor Commented:
i am sorry but i realized the mistake. The table name has to be same as file name. Also the table name should have extension. i.e. "select * from table_name.txt".
I am getting the results now after making the above changes.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.