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

Posted on 2005-04-05
Last Modified: 2008-01-09
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.'

Question by:picasothakkar
    LVL 30

    Expert Comment

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

    David Maisonave :-)

    Author Comment

    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;
    LVL 30

    Accepted Solution

    Have you tried using it without the userID and password?
    LVL 30

    Expert Comment

    Do you have the latest Microsoft Jet database engine installed?

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now