Solved

ASP.NET connection string problem

Posted on 2015-01-27
9
126 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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