3 Replies - 1152 Views - Last Post: 02 October 2012 - 01:38 PM

#1 Cyclopses  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 38
  • Joined: 20-January 11

Server errors connecting to host database.

Posted 18 September 2012 - 07:01 AM

It's been about a week and I still havn't figured it out,
I'm trying to connect to a database located on the hosts' server.
Few things to note out:
a) I transfered the database onto the host via Visual Studio's "include in project" and publish - to get away from auto-creation by server and more problems.
b ) I'm using a MVC architecture.
c) The database I created on my pc(and is published onto the website), is created by SQLEXPRESS, the server's SQL version is SQL Server 2005 non-express.
d) Am using the code first approach.

I've had an immense amount of different bugs from "database not found" issues to "login failures" and "application / failures" just too many to name.
It has all come down to these last more detailed errors, the last one being: :
Cannot open database "aspnetdb.mdf" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\SYSTEM'.


Can anyone guide me through setting these website configs right, cause it has to be up tomorrow and I'm really itching it now.

PS. web.config strings:
 
<connectionStrings>
<remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=aspnetdb.mdf;User Id=******; Password=******!;Integrated Security=True;" providerName="System.Data.SqlClient"/>


and
 <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>


alot of thanks to readers and posters alike.
John

Is This A Good Question/Topic? 0
  • +

Replies To: Server errors connecting to host database.

#2 Cyclopses  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 38
  • Joined: 20-January 11

Re: Server errors connecting to host database.

Posted 18 September 2012 - 09:06 AM

An interesting fact I just noticed while changing my database name is that by accident I am now able to create a database on the server automatically via code first and the framework entitiy.

It also drops the previous created database with a different name, which I found odd, might be because of the connectionStringName?
Was This Post Helpful? 0
  • +
  • -

#3 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Server errors connecting to host database.

Posted 21 September 2012 - 09:31 PM

did you solve the problem?
Was This Post Helpful? 0
  • +
  • -

#4 Cyclopses  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 38
  • Joined: 20-January 11

Re: Server errors connecting to host database.

Posted 02 October 2012 - 01:38 PM

Seems I did, I'm not really sure what string I had to pull to get it to work, there were so many tests I performed I got lost..
One thing I can point out is that I let my host create the database for me, and apply rights to it.
It was my host's server that couldn't find my database in the first place and couldn't access it cause I didn't setup permissions.

A long and boring story short, let your host create the database for you and set permissions, then access that database and fill it with tables.

EDIT 1: Extra sidenote, I changed the "Initial catalog" property of the web.config connectionstring to "aspnetdb" without the .mdf at the end, if it matters.

This post has been edited by Cyclopses: 02 October 2012 - 01:44 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1