1

I am trying to connect Ms Access database in CodeIgniter but I am getting following error Message: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect

My db connection.

$dbname = 'C:/xampp/htdocs/personal/naaz/TimeData 13april.mdb'; 
$access['dsn'] = "DRIVER={Microsoft Access Driver (* .mdb)}; DBQ= {$dbname}";
$access['hostname'] = "DRIVER={Microsoft Access Driver (* .mdb)}; DBQ= {$dbname}";
$access['username'] = "localhost";
$access['password'] = "";
$access['database'] = $dbname; 

$access['dbdriver'] = "odbc";
$access['dbprefix'] = "";
$access['pconnect'] = FALSE;
$access['db_debug'] = FALSE;
$access['cache_on'] = FALSE;
$access['cachedir'] = "";
$access['char_set'] = "utf8";
$access['dbcollat'] = "utf8_general_ci";
$access['swap_pre'] = '';
$access['autoinit'] = TRUE;
$access['stricton'] = FALSE;


$access_db = $this->load->database($access, true);

$result = $this->db->select('*')->get('user')->result_array(); 
print_r(json_encode($result));

please help anyone, any help would be appreciated.

Mohammed
  • 43
  • 1
  • 7
  • Did you read through [this](https://stackoverflow.com/a/58571741/231316)? Also, `(* .mdb)` looks suspicious, I'm pretty sure it should be `(*.mdb)` – Chris Haas Apr 13 '21 at 17:26
  • I remove the space but it won't solve – Mohammed Apr 13 '21 at 17:35
  • Did you also go through the link that I provided? If so, please post screenshots of your ODBC drivers for the bit-ness that PHP is running as, 32 or 64. – Chris Haas Apr 13 '21 at 17:40

0 Answers0