Re:Connectiion to sql2000 / sql2005 express
The only way I can think to do this would be to create a client side alias
that alias's the named instance in Server2, but I suspect that will not work
because the alias will have to be to machine name which will get resolved
somewhere in the protocol stack.
why is this a problem for you in the first place? You are hardwiring the
server name in the connection strings, sqlexpress is just the sql server
specific part of the name. In reality ha dpeople not been lazy when building
the protocol stack originball you would probably have had to connect to
server1\MS SQL because thats what you are actually doing, connecting to a
specific instance (pre sql 2000 there could only be one but thats not the
point) of sql server running on a specific machine.
Oh and Dennis is not 100% right, it is preferable to use sqlncli over
sqloledb when connecting to a 2005 instance but it will work as long as you
don't try and use new features.
"KG" <
XXXX@XXXXX.COM>writes
Quote
Platform - Delphi 7, sql2000, sql2005 epxress,ADO
I have two database ,one attach to SQL 2000 in server1, the other attach
to SQL2005 express in server2,
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=True;User
ID=xx;Password=xx;Data Source=server1;Initial Catalog=db'
This works fine in server 1 .
Connect to Server2 works only if I change to
'Datasource='server2\SQLEXPRESS' instead of 'Datasource=server2' . My
question is :
How do I retrieve the SQL server name , so that one connection string work
for two environment , and I need not hardcode 'SQLEXPRESS' in order to
connect to sql2005 .
( ** SERVER1 ,SERVER2 is computername )
Very much thanks .
KG