Tuesday, March 27, 2012

Connecting to SQL Server 2000 on Windows 2003 Server using sql-dmo

Hi
I have a strange problem connecting to a local SQL Server 2000 on a machine
running Windows 2003 Server.
I'm using a plain connection as shown in the code below:
Dim oServer as New SQLDMO.SQLServer
With oServer
.LoginTimeout = -1
.LoginSecure = True 'Use NT Authentication
.AutoReConnect = False
.Connect (strServerName)
End With
I'm connecting through the IP of the machine.
The problem is:
When I have a system32\drivers\etc\hosts entry specified pointing at the
same machine, then I cannot connect to the SQL Server using NT Authenticatio
n.
I can however still connect by using SA user.
Error is:
Runtime error '-2147203052 (80044814)':
[Microsoft][ODBC SQL Server Driver][SQL Server] Login failed for user
'(null)'. Reason: Not associated with a trusted SQL Server connection.
If I remove the hosts entry I can connect without problems using both NT
authentication and SA user.
It doesn't make any difference about the problem if I'm running NT
authentication mode or mixed mode.
This code having this problem has run without problems on Windows 2000
server, so it is an issue with Windows 2003 server.
Does anyone have a clue to what might cause this problem?
Thanx in advance
/BrianJust a note, if other people should have the same problem.
A temporary work-around is to define the entry in the Hosts entry as an
Alias in
SQL Server - Client Network Utility.
/Brian
"Brian Nielsen" wrote:

> Hi
> I have a strange problem connecting to a local SQL Server 2000 on a machin
e
> running Windows 2003 Server.
> I'm using a plain connection as shown in the code below:
> Dim oServer as New SQLDMO.SQLServer
> With oServer
> .LoginTimeout = -1
> .LoginSecure = True 'Use NT Authentication
> .AutoReConnect = False
> .Connect (strServerName)
> End With
> I'm connecting through the IP of the machine.
> The problem is:
> When I have a system32\drivers\etc\hosts entry specified pointing at the
> same machine, then I cannot connect to the SQL Server using NT Authenticat
ion.
> I can however still connect by using SA user.
> Error is:
> Runtime error '-2147203052 (80044814)':
> [Microsoft][ODBC SQL Server Driver][SQL Server] Login failed for user
> '(null)'. Reason: Not associated with a trusted SQL Server connection.
> If I remove the hosts entry I can connect without problems using both NT
> authentication and SA user.
> It doesn't make any difference about the problem if I'm running NT
> authentication mode or mixed mode.
> This code having this problem has run without problems on Windows 2000
> server, so it is an issue with Windows 2003 server.
> Does anyone have a clue to what might cause this problem?
> Thanx in advance
> /Brian

No comments:

Post a Comment