Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET connection string problem

Posted on 2015-01-27
9
Medium Priority
?
137 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
Independent Software Vendors: 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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