Wednesday, March 7, 2012

Another Connection Problem

Hi all,
I am starting to work with MSDE. I have no problem connecting to the Northwind db, but every time I create a new database, I can't open it.
I have used ...
"Data Source=MyTestDb;Initial Catalog=mytable;Integrated Security=SSPI;"
the error I receive is:
Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'MyTestDb'. Login fails. Login failed for user 'HOODWKOTC124874\ASPNET'.

I have also used...
what I thought was the default user id =sa; password =;

I can make a winform and drop sql objcets on the page and connect to the db that I created, just not through asp.net

FYI- I do not have Enterprise manager.

Any help would be appreciated.

ThanksOpen Enterprise manager and create a login for ASPNET and grant it perms on the MyTable db.

Hope that helps
Kashif|||I don't have enterprise manager. I am using the MSDE.|||You can use OSQL, included with MSDE. You need to have the folder that OSQL is in on your path, or be in that folder.

Using the command prompt, type the following, substituting your COMPUTERNAME and databasename:


osql -S servername\instancename -E -q
--Line numbers will appear
EXEC sp_grantlogin 'COMPUTERNAME\ASPNET'
go
use <databasename>
go
EXEC sp_grantdbaccess 'COMPUTERNAME\ASPNET'
go
EXEC sp_addrolemember 'db_owner', 'COMPUTERNAME\ASPNET'
go

No comments:

Post a Comment