Monday, March 12, 2012

How to use MSDE with security

I set MSDE DB (No user name,No password setting. window integrated security ONLY) in XP Pro.,
so I should not Login problem, anyone can get in, but I DO have a problem:
Login failed for user 'myPC\ASPNET'

Situation:
I used MSDE Database server. I drag and drop \northwind\Customers table to myWebForm,
it created connection and sqlDataAdapter, wrote code, sqlDataAdapter1.fill(dsCustomer,"Customers") in Page_Load block,
then run, got error message: Login failed for user 'myPC\ASPNET'

You still need to grant SQL Server login permissions to the ASPNETaccount. And you will likely need to give permissions to theASPNET account to access the Northwind database.

From the command prompt, this will connect you to your instance of MSDE and put you into an interactive mode with osql:
osql -E -S (local)

Now you can enter the commands in the interactive mode:

1>EXEC sp_grantlogin 'myPC\ASPNET'

2>GO

1>USE northwind

2>GO

1>EXEC sp_grantdbaccess 'myPC\ASPNET'

2>GO

1>EXIT

When you've completed this the ASPNET account should be able to connect to yourNorthwind database successfully.
Terri
|||Hi Terri,
It DID work, Greate !!! Thank you so much.
/Toby

No comments:

Post a Comment