"localhost" does not work in connection string

  • Thread starter Thread starter Ayush H N
  • Start date Start date
A

Ayush H N

Hello,

When we connect to MSDE using the following connection string we are not
successful. COS in this case refers to an instance of MSDE on our system.

ConnectionString=Provider=SQLOLEDB;Server=localhost\COS;User
ID=sa;Password=sa;Database=COS_1_1;

But the above works, if we replace localhost by the actual machine name
our server. In addition to this, the usage of localhost works if we
install MSDE without specifying INSTANCENAME i.e if we install only a
default instance. We really need it to work for localhost\<instance-name>.

Note: We are using DISABLENETWORKPROTOCOLS=0 as an option during
installation.

We'd be grateful to anyone who can throw some light on this topic.


Thank you,
Ayush H N
 
There's code at the URL below to get the computer's name. You could use it
to dynamically create the connection string, something like this ...

strConnectionString = "Provider=SQLOLEDB;Server=" & fOSComputerName() &
"\COS;" etc.

http://www.mvps.org/access/api/api0009.htm

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
« localhost » is for the web server, not the SQL-Server.

For SQL-Server, it's the word « local » enclosed in parenthesis: (local)

S. L.
 
or, if you just want to save keystrokes, referring to the local machine can
also be a single period.
 
Back
Top