Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL server does not exist or access denied

Status
Not open for further replies.

lehuong

Programmer
Sep 2, 2003
98
US
Hi all,
I have this error "SQL server does not exist or access denied" whenever I try to access the database. I can access the database in my local machine,say: http:\\localhost\mysite.htm ... (This one is for testing, I need to public this website from other machine)
But now, I move the site to other machine and run these same queries again into the microsoft sql server 2000 of that machine:

QUERY:
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'PLUS')
DROP DATABASE [PLUS]
GO

CREATE DATABASE [PLUS]
GO

Print 'Okay, database created'

use [PLUS]
GO



Print 'Okay, objects dropped'


Print 'Creating PLUSUserLogin'

/****** Object: Login PLUSUser Script Date: 8/29/2001 4:52:14 AM ******/
if not exists (select * from master.dbo.syslogins where loginname = N'PLUSUser')
BEGIN
declare @logindb nvarchar(132), @loginlang nvarchar(132) select @logindb = N'PLUS', @loginlang = N'us_english'
if @logindb is null or not exists (select * from master.dbo.sysdatabases where name = @logindb)
select @logindb = N'master'
if @loginlang is null or (not exists (select * from master.dbo.syslanguages where name = @loginlang) and @loginlang <> N'us_english')
select @loginlang = @@language
exec sp_addlogin N'PLUSUser', 'secret', @logindb, @loginlang
END
GO

/****** Object: User dbo Script Date: 8/29/2001 4:52:14 AM ******/
/****** Object: User PLUSUser Script Date: 8/29/2001 4:52:14 AM ******/

if not exists (select * from dbo.sysusers where name = N'PLUSUser' and uid < 16382)
EXEC sp_grantdbaccess N'PLUSUser', N'PLUSUser'
GO

/****** Object: User PLUSUser Script Date: 8/29/2001 4:52:14 AM ******/
exec sp_addrolemember N'db_owner', N'PLUSUser'
GO


Print 'Okay, login added'

Print 'Creating tables...'
CREATE TABLE UserList
(
u_id INT NOT NULL IDENTITY,
u_username VARCHAR( 100 ),
u_password VARCHAR( 100 )
)

but the when I tried the same connection string:
&quot;Server=localhost;UID=PLUSUser;PWD=secret;Database=PLUS&quot;

it came up the error &quot;SQL server does not exist or access denied&quot;.

ps: There are 3 SQL server in this machine. localserver, server1, server2

Thanks
lehuong
 
Hi,
The problem is in your connection string. The server referred to in the connection string is the SQL Server you are trying to connect to. The SQL Server must have the UID as a valid user, with appropriate rights to the database you are trying to access.

HTH --
Lorraine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top