Python Forum
how do I successfully use PDO with my ODBC for MSSQL?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I successfully use PDO with my ODBC for MSSQL?
#1
  • Windows Server 2016 64 bit (Fully Updated)
  • WAMP/3.1.3 (Win32)
  • Apache/2.4.33 (Win32)
  • PHP/7.2.4 (Win32)

I am trying to connect to my database on a SQL Server but can't seem to get the connection working. I have tried several approaches, downloaded files, enabled extensions but none of them seem to work. I have established that the SQL Server has Named Pipes and that Remote Connections are allowed. I have also confirmed that he password and username work:

<?php

$driver='{ODBC Driver 17 for SQL Server}';
/* $driver='{ODBC Driver 13 for SQL Server}'; */
/* $driver='{ODBC Driver 11 for SQL Server}'; */
$dsn='phpodbc11';
$hostname='host01';
$database='data01';
$username='root';
$password='pass123';

$conn = new PDO("odbc:$dns")
$conn = new PDO("dblib:host=$hostname;dbname=$database", $username,$password);
$conn = new PDO("sqlsrv:Server=$hostname;Database=$database", $username, $password);
$conn = new PDO("odbc:Driver=$driver;Server=$hostname;Database=$database", $username, $password);

?>
[Image: AsZoR.jpg]

[Image: D2PiO.jpg]

php.ini extensions :
  • extension=pdo_odbc
  • extension=php_mysqli.dll
  • extension=php_ldap.dll
  • extension=php_pdo_sqlsrv_72_ts_x86.dll
  • extension=php_sqlsrv_72_ts_x86.dll

Errors I get for each of the aforementioned new PDO attempts

SQLSTATE[IM002] SQLConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

could not find driver

SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x86: https://go.microsoft.com/fwlink/?LinkId=163712

SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Reply


Messages In This Thread
how do I successfully use PDO with my ODBC for MSSQL? - by cyberion1985 - Jun-26-2018, 06:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python connect to mssql wailoonho 7 2,112 Dec-07-2023, 02:06 AM
Last Post: wailoonho
Sad Can anyone help me successfully run this code? TheMouseAvenger 26 4,325 Sep-22-2023, 02:51 PM
Last Post: snippsat
  MSSQL query not working in Python kat35601 0 995 Apr-12-2022, 06:44 PM
Last Post: kat35601
  from MSSQL to excel kat35601 1 1,772 Apr-11-2022, 06:19 PM
Last Post: buran
  ssues with importing data from ODBC Slavek_d 1 1,510 Feb-01-2022, 09:57 AM
Last Post: ibreeden
  ODBC iPhone to PC KipCarter 0 1,585 Feb-19-2020, 11:53 AM
Last Post: KipCarter
  accessing Sybase (ASE and/or Anywhere) via ODBC... on Linux zatlas1 0 2,971 Jan-31-2019, 06:48 PM
Last Post: zatlas1
  [split] How to insert JSON into MSSQL gehrenfeld 3 3,429 Jan-27-2019, 06:20 PM
Last Post: micseydel
  How to insert JSON into MSSQL raysefo 2 4,230 Jan-27-2019, 06:17 PM
Last Post: micseydel
  Interface Arduino and MSSQL using Python MichaelDean 0 3,000 Nov-18-2018, 05:00 PM
Last Post: MichaelDean

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020