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
Related
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
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
My system OS is 64-bit. Ms Access 2007 is 32 bit. I have connect with PHP.
PHP file give following error:
"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 C:\wamp\www\PI\Connection.php on line 3"
Connection.php
<?php
$con = odbc_connect("Driver={Microsoft Access Driver (*.mdb,*.accdb)};Dbq=PIInstitute","","");
if($con){
echo "Connected";
}else{
echo "Failed";
}
?>
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);
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?