sql connection with VS2008

Posted on 2008-11-11
Last Modified: 2013-11-27

I use VS 2008 and SQL express 2005

When I connect to database through Sql server managment studio express then when I want to connect to the same database with VS 2008 or program that I created i get error

Cannot open user default database. Login failed. Login failed for user 'domain\user'.

After reboot pc and first connect with program or VS then I can connect to database but then I can't connect with sql server menagment

I get the same error

everything I do localy I just start to learn sql and VB. Looks like I can't connect more then once with the same user. Even if i shut down booth aplication  I can't connect to database after. I need reboot pc to connect to.
Question by:gowerman
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    >Cannot open user default database.

    that means that the login 'domain\user' has a default database specified which does not exist, or to which that login has no permissions to.
    double check the logins setting (ie reset the default database to "master")...

    Author Comment

    but I can connect to database with this login  after reboot pc

    Expert Comment

    I have the same issue; however, I am using VS C# express 2008 with the SQL express 2008. My original database was backed up on another system and then restored that backup into SQL express 2008. The issue is it makes development with a database a bit difficult b/c I have to reboot each time I need to work with the database between C# and SQL.

    Expert Comment

    Forgot to add my original database came from sql express 2005.

    Accepted Solution

    The problem was that i connect to a file. Now Im using

     Dim sqlconnection1 As New SqlConnection("Data Source=.\SQLEXPRESS;Database=xxxxx;Trusted_Connection=True")


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
    With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now