Can't connect to SQL Server via ODBC

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Son Volt
Forum Newbie
Posts: 19
Joined: Tue Jul 11, 2006 1:36 pm

Can't connect to SQL Server via ODBC

Post by Son Volt »

I just installed PHP 5.1.4 with SQL Server 2005 on my laptop. PHP is running fine and so is SQL Server 2005. When I try to connect to SQL Server from my my PHP code I get this 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\index.php on line 5

Here's my connection string that is causing the error

$connect_id = odbc_connect("Driver={SQL Server};Server=mydbname;Database=myDB","myUser", "myPass");


Any idea what's wrong? This is driving me nutts.. I installed PHP on my computer at home and had no problem connecting to SQL Server. It's like this laptop is cursed.

thanks,
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Is SQL Server running? Can you connect to it through Enterprise Manager or some other DB Utility?
Son Volt
Forum Newbie
Posts: 19
Joined: Tue Jul 11, 2006 1:36 pm

Post by Son Volt »

Everah wrote:Is SQL Server running? Can you connect to it through Enterprise Manager or some other DB Utility?

Yes... SQL Server is running and I can connect via the client tools.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I googled your error message and found this thread at the top of the list.
Post Reply