Hello everyone,
I'm currently getting 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 in c:\Inetpub\wwwroot\~phpdesigner_outputlocal_tmp~2278.php on line 4
Couldn't connect to datasource.
I'm currently running PHP5 V5.1.4, MS SQL Server 2005, and IIS V5.1
The code I'm using to connect is the following:
<?
// Connect to the ODBC datasource 'accessBase1'
//$myDSN = "SERVER=sqlserver;DATABASE=testDatabase;Trusted_Connection=yes";
$connect = odbc_connect("SERVER=sqlserver;DATABASE=testDatabase;Trusted_Connection=yes","user","") or die("Couldn't connect to datasource.");
//$connect = odbc_connect("msaccess","","") or die("Couldn't connect to datasource.");
// form query statement
$query = "SELECT column1 FROM testTable";
// prepare query statement
$result = odbc_prepare($connect,$query);
// execute query statement and display results
odbc_execute($result);
odbc_result_all($result,"border=1");
// We're done with the query results, so free memory
odbc_free_result($result);
// close connection
odbc_close($connect);
?>
I'm able to connect to ms access using odbc. However, I'm unable to connect to the ms sql server which is on a webserver not my local machine.
In addition, I've tested my odbc connection by pressing "Test Connection" while configuring my DNS, and this is the result:
Microsoft SQL Server ODBC Driver Version 03.85.1117
Data Source Name: sqlserver
Data Source Description: SQL Server DSN
Server: adsvapp02
Database: (Default)
Language: (Default)
Translate Character Data: Yes
Log Long Running Queries: No
Log Driver Statistics: No
Use Integrated Security: Yes
Use Regional Settings: No
Prepared Statements Option: Drop temporary procedures on disconnect
Use Failover Server: No
Use ANSI Quoted Identifiers: Yes
Use ANSI Null, Paddings and Warnings: Yes
Data Encryption: No
Microsoft SQL Server ODBC Driver Version 03.85.1117
Running connectivity tests...
Attempting connection
Connection established
Verifying option settings
Disconnecting from server
TESTS COMPLETED SUCCESSFULLY!
Any help will be greatly appreciated! đ