• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

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

0
picasothakkar
Asked:
picasothakkar
  • 3
  • 2
1 Solution
 
AxterCommented:
Hi picasothakkar,
Please show us the conection string you're using.

David Maisonave :-)
Cheers!
0
 
picasothakkarAuthor Commented:
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;
      }
}
0
 
AxterCommented:
Have you tried using it without the userID and password?
0
 
AxterCommented:
Do you have the latest Microsoft Jet database engine installed?
0
 
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now