sql connection with VS2008


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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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")...
gowermanAuthor Commented:
but I can connect to database with this login  after reboot pc
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.
Forgot to add my original database came from sql express 2005.
gowermanAuthor Commented:
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")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.