Link to home
Start Free TrialLog in
Avatar of picasothakkar
picasothakkar

asked on

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.'

Avatar of Axter
Axter
Flag of United States of America image

Hi picasothakkar,
Please show us the conection string you're using.

David Maisonave :-)
Cheers!
Avatar of picasothakkar
picasothakkar

ASKER

the application is using the following method to establish the connection

odbc::Connection *
OdbcDirectory::OpenOdbcConnection(
            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;
      }
}
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you have the latest Microsoft Jet database engine installed?
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.