Connection string not working when moving from sqlexpress to sqlserver

J

John

Hi

I am manually able to create a connection to my db in the vs2005 ide using
Tools->Connect to Database. In the connection I see 'Data
Source=MYSERVER;Initial Catalog=aspnetdb;Integrated Security=True' as the
connection string and 'NET Framework Data Provider for SQL Server' as the
provider. Following these settings in my code and I have used the connection
string;

<add name="Membership" connectionString="Data Source=MYSERVER;Initial
Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient"/>

in my app's web.config file. This connection is then used by a custom
membership provider for the create user wizard. Now when I try to create a
new user in the wizard I get the following error;

System.Data.SqlClient.SqlException: Cannot open database "aspnetdb"
requested by the login. The login failed.
Login failed for user 'MYSERVER\ASPNET'.

I was able to work fine when the db was on sql express. What is the problem
and how can I fix it?

Thanks

Regards
 
S

S. Justin Gengo

John,

When you connect to the database using integrated security from the ide the
application passes your credentials to the database. When ASP.NET is running
as a server and using integrated security it is passing the credentials that
your website is running as (most likely IUSR_[MachineName]) you'll need to
give whichever user account your site is running under the appropriate
permissions to the database.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
P

Paul Clement

¤ Hi
¤
¤ I am manually able to create a connection to my db in the vs2005 ide using
¤ Tools->Connect to Database. In the connection I see 'Data
¤ Source=MYSERVER;Initial Catalog=aspnetdb;Integrated Security=True' as the
¤ connection string and 'NET Framework Data Provider for SQL Server' as the
¤ provider. Following these settings in my code and I have used the connection
¤ string;
¤
¤ <add name="Membership" connectionString="Data Source=MYSERVER;Initial
¤ Catalog=aspnetdb;Integrated Security=True"
¤ providerName="System.Data.SqlClient"/>
¤
¤ in my app's web.config file. This connection is then used by a custom
¤ membership provider for the create user wizard. Now when I try to create a
¤ new user in the wizard I get the following error;
¤
¤ System.Data.SqlClient.SqlException: Cannot open database "aspnetdb"
¤ requested by the login. The login failed.
¤ Login failed for user 'MYSERVER\ASPNET'.
¤
¤ I was able to work fine when the db was on sql express. What is the problem
¤ and how can I fix it?
¤

Try enabling impersonation in your web.config. file.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top