Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7996081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:36:48+00:00 2026-06-04T14:36:48+00:00

I’m attempting to read from an Access database using MDBTools drivers to execute an

  • 0

I’m attempting to read from an Access database using MDBTools drivers to execute an odbc_connect on Ubuntu 11.10. It’s working fine when using the DSN setup in /etc/odbc.ini.

Below are the contents of /etc/odbc.ini:

[logindb]
Description = Microsoft Access Try DB
Driver = MDBToolsODBC
Database = /home/folder1/TestDb.mdb
Servername = localhost

The Driver attribute in odbc.ini references MDBToolsODBC, so, here is my odbc setup in /etc/odbcinst.ini:

[MDBToolsODBC]
Description = MDB Tools ODBC
Driver = /usr/lib/libmdbodbc.so.0
Setup =
FileUsage =
CPTimeout =
CPReuse =

My problem is, when using $conn = odbc_connect('logindb','','');, I have to use the hardcoded value for the database location. Ideally, I would like to specify the first parameter of odbc_connect using a DSN-less connection, so that my database file can be a variable (will be reading from different dbs). Something like:

if ($cond1) {
  $db = "/home/folder1/TestDb.mdb";
} else {
  $db = "/home/folder1/TestDb2.mdb";
}

$conn = odbc_connect("odbc:Driver={MDBToolsODBC};Dbq=$db",'','');

I’ve also tried it without the odbc: prefix, but it did not work. Can anyone tell me why specifying the DSN works, but when trying to specify it on the fly using what looks like the same attributes, it doesn’t work? I’m thinking it has to do with the parameters and contents of the first parameter in the DSN-less connection. As always, any help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:36:49+00:00Added an answer on June 4, 2026 at 2:36 pm

    I think it might not support it. Going from the source of the actual driver you see that it loads the params it needs to check, checks wether it has been given a DNS string, checks the ini files next and if it hasn’t errored out it sets the params.

    for reference from odbc.c latest mdb-tools (mdbtools-0.6pre1)

    SQLRETURN SQL_API SQLDriverConnect(
    SQLHDBC            hdbc,
    SQLHWND            hwnd,
    SQLCHAR FAR       *szConnStrIn,
    SQLSMALLINT        cbConnStrIn,
    SQLCHAR FAR       *szConnStrOut,
    SQLSMALLINT        cbConnStrOutMax,
    SQLSMALLINT FAR   *pcbConnStrOut,
    SQLUSMALLINT       fDriverCompletion)
    {
    SQLCHAR FAR* dsn = NULL;
    SQLCHAR FAR* database = NULL;
    ConnectParams* params;
    SQLRETURN ret;
    
    TRACE("DriverConnect");
    
    strcpy (lastError, "");
    
    params = ((ODBCConnection*) hdbc)->params;
    
    if (!(dsn = ExtractDSN (params, szConnStrIn)))
    {
      LogError ("Could not find DSN in connect string");
      return SQL_ERROR;
    }
    else if (!LookupDSN (params, dsn))
    {
      LogError ("Could not find DSN in odbc.ini");
      return SQL_ERROR;
    }
    else 
    {
      SetConnectString (params, szConnStrIn);
    
      if (!(database = GetConnectParam (params, "Database")))
      {
     LogError ("Could not find Database parameter");
     return SQL_ERROR;
      }
    }
    ret = do_connect (hdbc, database);
    return ret;
    

    then when you verify in connectparams.c, ExtractDSN specifically looks for the DSN= string

     gchar* ExtractDSN (ConnectParams* params, const gchar* connectString)
     {
      char *p, *q, *s;
    
      if (!params)
      return NULL;
      /*
       * Position ourselves to the beginning of "DSN"
      */
      p = strstr (connectString, "DSN");
     if (!p) return NULL;
     /*
      * Position ourselves to the "="
      */
     q = strchr (p, '=');
     if (!q) return NULL;
    

    And LookupDSN looks for inifiles or immediately returns with TRUE, depending on the HAVE_SQLGETPRIVATEPROFILESTRING precompiler setting.

    So given that

    SetConnectString (params, szConnStrIn);
    

    only works on the data it got from the 2 previous functions, I think it doesn’t support DSN-less. Only either a proper DSN= string or ini files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.