Solved

ASP.NET connection string problem

Posted on 2015-01-27
9
124 Views
Last Modified: 2015-02-04
Using Visual Studio 2013, I created a local database to handle memberships and roles.  When I try to login on the desktop version, everything works fine.  When I tried to login on the server version of the website, I got an error message.  Another expert said I need to get rid of the LocalDB connection string, and replace it with something like this:

    <add name="DefaultConnection" connectionString="Server=72.18.135.38,1533;Database=aspnet-WillowLane1-f59c4ece-32dd-40f4-9451-1620648a0486.mdf;Uid=xxxxxx;Password=xxxxxx;"
      providerName="System.Data.SqlClient" />

I don't get the error anymore, but my logins always fail.  When I created the database, I was never asked for a username and password.  What should I be using?
0
Comment
Question by:rrhandle8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40572423
Few initial questions.

1) What was the error you were originally getting before you changed the connection string?
2) How are you creating/deploying your database? i.e. are you using a code-first, or model first deployment?
3) Where you using LocalDB on your machine to develop against?
4) What version of SQL is on your server where you are deploying to?
0
 

Author Comment

by:rrhandle8
ID: 40573523
I honestly forgot the previous error.  
Yes I was using LocalDB on my machine.
Database on server is MSSQL 2005.
I was using Code-First.
I have received some feedback from support.  The sent me this connectionstring:

 <add name="DefaultConnection" connectionString="Server=.\SQLExpress;AttachDbFilename=C:\HostingSpaces\inomaxne\willowlanecare.inomax.net\wwwroot\App_Data\[database name goes here};Trusted_Connection=Yes;" providerName="System.Data.SqlClient" />

Now I am getting the error:

CREATE DATABASE permission denied in database 'master'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.

Source Error:


Line 22:             ' Validate the user password
Line 23:             Dim manager = New UserManager()
Line 24:             Dim user As ApplicationUser = manager.Find(UserName.Text, Password.Text)
Line 25:             If user IsNot Nothing Then
Line 26:                 IdentityHelper.SignIn(manager, user, RememberMe.Checked)


If you want to see the stack, go to http://willowlanecare.inomax.net, Try to login.
0
 

Author Comment

by:rrhandle8
ID: 40573626
A good article from Microsoft on connection strings to be used in this case.  I have tried all the combination, still nothing works.

https://msdn.microsoft.com/en-us/library/jj653752%28v=vs.110%29.aspx#datasource
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40573649
That error means that the account you are connecting to the SQL Server with (probably the local system account, but basically whatever account IIS is running under) doesn't have CREATE DATABASE permissions on the server.

Personally I'm not a huge fan of an IIS service account having permissions to create databases. But that is what your issue is. So, with that in mind, you either need a named user account in SQL Server that does have CREATE DATABASE permissions, and then use that in your connection string, or you need to give CREATE DATABASE permissions to the IIS service account.
0
 

Author Comment

by:rrhandle8
ID: 40573674
That is the result of one combination of many connection strings I have been experimenting with. Notice in the msdn article above there is no mention of needing those permission.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40573698
You won't need those permission when using LocalDB, but you will need them if you're trying to attach a database to a full blown SQL Server. You'll also need to make sure the account has read/write access to the directory where the database files are located.
0
 

Author Comment

by:rrhandle8
ID: 40581759
Carl,
Is it OK to use the LocalDB on the production server for a simple little site that will have 10 to 20 visitors a day?  Someone sent me this link https://stackoverflow.com/questions/13571331/is-it-normal-to-use-localdb-in-production
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40585818
According to that post, and the two articles it points at, it is.  Although you need to jump through a couple of loops to get it to work.

Personally I wouldn't, I would use SQL Express as a minimum. I've never really used SQL Express in a production environment either - that's not to say you can't, or shouldn't, but most environments i've worked in there has been a full-blown SQL install available.
0
 

Author Closing Comment

by:rrhandle8
ID: 40590020
Enough!  I got a separate domain name and a shared hosting account with SQL Server Web.  It works now.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
API v SOA 8 63
Change the color of spectfic dates in date picker control asp.net 28 54
async questions 5 47
What is needed to become a DBA? 7 49
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question