Solved

MS-SQL connect fails on a database with a hyphen in the name.

Posted on 2004-10-08
6
359 Views
Last Modified: 2012-05-05
Hi there,

I am using mssql_select_db as part of ADODB 4.5.3 under PHP 4.3.9 on windows XPsp1

I have modified the SelectDb method to echo out some parameters as it goes...

Attepting connection to uk-argo-asp-01_LM_W3SVC_1_Collab
ConnectionID = Resource id #7
calling mssql_select_db('uk-argo-asp-01_LM_W3SVC_1_Collab')

Then the mssql_select_db(...) is called and this error is outputted with connection debug on.

127.1.1.104: Could not locate entry in sysdatabases for database 'uk'. No entry found with that name. Make sure that the name is entered correctly.

My connection to, and credentials on the database are sound as I can connect to the Northwind database (with a different erro regarding ODBC version and ntext).

The problem is that the mssql_... appears to be truncating the name. However, I did have ADODB version 2.42 and this did not appear to happen, but I am forced to upgrade as I require funcionality in the new version.

Any ideas how I can escape the name, or fix the problem?

Thanks in advance.
0
Comment
Question by:nigel5
  • 3
6 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12258933
some guessing work: use [] brackets

mssql_select_db('[uk-argo-asp-01_LM_W3SVC_1_Collab]')


0
 

Author Comment

by:nigel5
ID: 12258958
Oh, I have also loaded the latest MDAC (2.8)
0
 

Author Comment

by:nigel5
ID: 12259277
The brackets doesn't work...

calling mssql_select_db('[uk-argo-asp-01_LM_W3SVC_1_Collab]')
127.1.1.104: Line 1: Incorrect syntax near 'uk-argo-asp-01_LM_W3SVC_1_Col'.

Another stab in the dark was double quotes, as exepected no difference.
0
 

Author Comment

by:nigel5
ID: 12268337
I have found the answer...

DSN-less connection via ODBC...

  $db_name = "uk-argo-asp-01_LM_W3SVC_1_Collab";
  $server = "localhost";
  $dsn = "Driver={SQL Server};Server=$server;Database=$db_name;";
  $mssqlconn = &ADONewConnection('odbc');
  $mssqlconn->Connect($dsn, $db_user, $db_pass);
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12520273
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now