www.webdeveloper.com
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2011
    Posts
    103

    trouble connecting to database

    Hi. I've imported an mvc project that I did not build myself, and I'm trying to open it in Visual Web Developer 2010 Express. I keep getting this error when I run Debug:

    Code:
    Cannot open database "DatabaseName" requested by the login. The login failed.
    Login failed for user UserName
    Now, I'm very new to asp.net, so I don't really know where to begin. I do notice that databases I've created in my own projects have had the .sdf file extension, whereas the database I'm failing to connect to is .mdf. Also, I don't see the .mdf in the App_Data folder in the Solution panel (I'm guessing this could very well be the problem).

    Another possibility is that the problem is with the connectionString in Web.config. This is the default connectionString that Visual Web Developer gives me when I create a project, but it don't work
    Code:
    <add name="ApplicationServices"
             connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
             providerName="System.Data.SqlClient" />
    What is the most likely cause of this error?

  2. #2
    Join Date
    Mar 2006
    Location
    Discworld
    Posts
    75
    Error say that you either do not have database with which you attempt to connect or your user does not have authorization to connect to that database.
    First of all do you even have this "default" database aspnetdb.mdf?
    Installing Visual Web Developer 2010 Express does not exactly means that you installed SQL Express as well.
    Check if you have services for SQL running in task manager and if you do - download SQL management studio and see what you really have there and what users can work with your database.
    Apply your discoveries to connection string, first start with creating ODBC (administrative tools) with credentials you find to connect to your database. This way you can be sure that connection string will have proper values.
    Good luck.

    ps. Do you know that you can download fully functional SQL server and run it for about 120 days on your local system for testing/learning purposes.
    That would solve many problems for you and let you really learn NET full potential. SQL express is kind of dummy version and not really good especially for beginer.
    Last edited by alexsts; 06-08-2012 at 09:22 AM.

    Please consider the
    environment before printing

  3. #3
    Join Date
    Mar 2011
    Posts
    103
    Hi. Thanks for your reply. I have "SQL Server 2008 R2" and "SQL Server 2008" listed in my Programs menu (will these stop working after 120 days? I didn't pay for them, they installed themselves when I installed VS Express).

    I tried SQL management studio, but couldn't get it to work. In the end, I just used a connection string that connects to the live database. That should suffice for now.

  4. #4
    Join Date
    Mar 2006
    Location
    Discworld
    Posts
    75
    if you have evaluation version than yes; but if you have fully functional version then you should have this in your start menu: SQL Server Management Studio and it should work.
    And what exactly you could not make work in management studio?

    Please consider the
    environment before printing

  5. #5
    Join Date
    Mar 2011
    Posts
    103
    I was trying to use the 2005 version of the management studio, which I guess was the problem. I just couldn't find any connections.

  6. #6
    Join Date
    Mar 2006
    Location
    Discworld
    Posts
    75
    Man, 2005 studio will never work with 2008 SQL server.
    It will not even see it. Welcome to Microsoft bs.

    Please consider the
    environment before printing

  7. #7
    Join Date
    Mar 2011
    Posts
    103
    Indeed. Thanks for saying it. Microsoft DB configuration and use is orders of magnitude more complicated than mysql on linux. But I must say, asp.net does have some very sweet features.

  8. #8
    Join Date
    Mar 2006
    Location
    Discworld
    Posts
    75
    indeed.
    Unfortunately for MySQL functionality available there is way down when compare to MS SQL. Back to the topic.
    So do you have Management studio up and running?
    I was surprised to see after I installed WD Express that it did install instance SQL server Express but does not have any useful databases in it. That is probably your case as well.

    Please consider the
    environment before printing

  9. #9

    Thumbs up Nano Web Tech

    Thanks for the solutions now i have resolved this error.

    regards,

    Outsource Web Development Services

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles