ODBC connectivity in PHP - php

I have created an ODBC DSN (icamexamdata) for a MS Access DB. Mine is Win 7 OS. I used the following code to connect to the DSN
$conn=odbc_connect('icamexamdata','','');
I couldn't connect and I get the following error.
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect
Can anybody help?

Related

Error with SQL_ODBC_CURSORS during initialization PDO

When I try to initialize a new instance of the PDO class using the odbc driver, I get the following error.
Error: PDO Error: SQLSTATE[HY024] SQLSetConnectAttr SQL_ODBC_CURSORS: 0 [unixODBC][Driver Manager]Invalid attribute value
Why can I get this error?
I tried to find similar problems, but I did not find anything similar. Partially similar problems were solved by the advice to install Microsoft ODBC Driver 17 for SQL Server, I have it
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.1.1
UsageCount=1
but the problem is still there

MS Access ODBC connection issue with php

Warning: odbc_connect(): SQL error: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied., SQL state 08001 in SQLConnect in C:\xampp\htdocs\Admin\index.php on line 9

How to connect php to ms sql 2017

I am using php 5.6.28 and Ms sql express server 2017.
I add the following code.
$cid = odbc_connect("DESKTOP-9LIFSBQ\SQLEXPRESS","testdb","");
if (!$cid){
exit("<strong>Error.</strong>");
}
I got the following errors .
Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in

how to find ODBC driver name?

I am using PHP 5.5 and ODBC installed and active but still I have that error I couldn't connect the server. I Guess I need odbc driver name.
$conn = "DRIVER={SQL Server};SERVER=$server;DATABASE=$db";
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in
You can be using PDO to connect. If you are on windows:
$this->stmt = new PDO ("sqlsrv:server=$server;Database=$database;",$user,$pass);
On Linux:
$this->stmt = new PDO ("dblib:host=$server;dbname=$database;charset=UTF-8;",$user,$pass);

MS Access DB in php 64bit SQL state IM002 error

I'm trying to fetch data from access db in php. Code works fine for 32 bit php( I've tested in php version>5), but code generates error for 64bit php wamp.
Error Message: Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in
What I've tried : How can I correct this error: Data source name not found and no default driver specified
Code :
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$db", "","");
$tabs = odbc_tables($connection);
Is there any solution or I've to install 32 bit version?
Microsoft Access Driver (*.mdb)
refers to the older Access "Jet" driver which is installed as part of Windows itself but is only available to 32-bit applications. (There is no 64-bit version of Jet.)
You could download and install the 64-bit version of the newer Access Database Engine (a.k.a. "ACE", available here) and then use
Microsoft Access Driver (*.mdb, *.accdb)
as the driver name. (Assuming that the WAMP server does not already have a copy of Access 2007 or later installed on it.)

Categories