title: ODBC for MS Access Setup
body: <p>I'm working on getting an ODBC connection in place but would like some assistance in making sure the setup is correct.  I'm also hoping I can get some help in writing the PHP code to verify the connection to the DB is working.</p>
  
  <p>On a Windows Server 2008 R2 machine, I browse to C:\Windows\SysWOW64 and run odbcad32.  (This is where I start getting confused...most pages I've looked at give pretty basic information for this.)  The DB is a MS Access file.  Which tab do I choose...User DSN...System DSN...File DSN?</p>
  
  <p>Once I choose the correct tab, am I correct in entering anything for the Data Source Name?  (For instance, even though the file is 'it.accdb', can I put name the data source 'Employees'?  'Employees.accdb'?  Or does it have to match the actual file name?</p>
  
  <p>Finally, what would the PHP code be to connect to the DB?  The DB is currently D:\Temp\IT.accdb.  I've got the ODBC currently configured in the System DSN tab with a Data Source Name of 'Employees' and pointing to the DB.  I've tried the following code:</p>
  
  <pre><code>&lt;?php
  $dbName = "Employees";
  
  if (!file_exists($dbName)) {
     die("Could not find database file.");
  }
  $db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb,*.accdb)}; DBQ=$dbName; Uid=; Pwd=;");
  </code></pre>
  
  <p>I've tried changing $dbName to be a variety of things but everything I've tried results in not finding the database file.</p>
  
  <p>Can someone help me with this?</p>