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)
 
Joined
Oct 16, 2006
Messages
1
Reaction score
0
I think this will help some

User instances are not supported in common language runtime (CLR) code that is running inside of SQL Server. An InvalidOperationException is thrown if Open is called on a SqlConnection that has User Instance=true in the connection string.
The network protocol for user instances must be local Named Pipes. A user instance cannot be started on a remote instance of SQL Server, and SQL Server logins are not allowed.
So basically to deploy your application to the real world I recomend this: First attach the .mdf file to the SQL Express back it up then restore as a new DataBase then change your sql connection string in the web.config file to disable user instance then give the ASPNET account login permission on the server and the specific database.

Now for those of you who got the Login Controls to work but doesn't work remotely when viewed from the Internet; simply IExplore 6.0 doesn't handle the authentication ticket very well when your DNS its being "URLRedirected" or using "Frames" so just change the settings for your domain to do just the plain old "IP Address redirect to" method.

I hope this helps someone.

I am just a newbie trying to learn!

Darkonekt
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top