Hi,

I am running the following:

"DECLARE @error integer
DECLARE @osqlserver integer
DECLARE @errormsg VARCHAR(500)
DECLARE @Errorsource VARCHAR(500)
DECLARE @ErrorDesc VARCHAR(500)

-- Create an object that points to the SQL Server
EXEC @error = sp_OACreate 'SQLDMO.SQLServer', @osqlserver OUT
IF @error <> 0
BEGIN
set @errormsg = 'Error: '+ cast (@error as varchar(100))
raiserror(@errormsg, 16, 1 )
-- RETURN
END

exec @error = sp_oasetproperty @osqlserver, 'LoginSecure', -1
if @error <> 0
begin
raiserror('(SWERROR) Unable to set connection type (ID:001002)', 16, 1 )
-- return -1
end

exec @Error = sp_OAMethod @osqlserver, 'Connect', NULL, @@SERVERNAME
IF @Error <> 0
begin
EXEC sp_OAGetErrorInfo @error, @ErrorSource OUT, @ErrorDesc OUT
PRINT 'Error : ' + @ErrorSource + ' ' + @ErrorDesc
-- return -1
End"


The 'sp_OAMethod @osqlserver, 'Connect', NULL, @@SERVERNAME' statement fails, even though @@SERVERNAME and @osqlserver are valid.

The error is as follows:

Error : ODSOLE Extended Procedure [Microsoft][ODBC SQL Server
Driver][Shared Memory]SQL Server does not exist or access denied.
[Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen
(Connect()).

Any ideas as to what this problem is?

Thanks in advance for any guidance supplied.

Cheers.