views:

50

answers:

3

When I attempt to make a connection from my console app to my sqlExpress. I get the following error:

The user is not associated with a trusted SQL Server connection.

I have:

      Switched users
      Switched passwords
      Switched Servers
      Switched Databases

I always get the same error. I am using VS 2010 and Sql Server 2005

Here is my current connection string

SqlDatabase sqlDatabase = new SqlDatabase(@"Server=localmachineName\SQLEXPRESS;   database=database1;user id=username; password=mypassword;");
+2  A: 

You're missing a ; between username and password.

Anders Abel
My mistake. I have been switching the string around often and didn't include the ; in the current code section. I went back and corrected the did not solve the problem.
dan_vitch
+3  A: 

Is sql authorization enabled?

Check this if you haven't already: http://www.hosting.com/support/vps/windows/mixedmode/

MatthewMartin
I made the above change. I received a new error.Cannot open database "MyDatabase" requested by the login. The login failed.Login failed for user 'mylogin'.
dan_vitch
You probably have created a sql login (which gets you to the SQL server), but not given access for that login to a particular db.http://technet.microsoft.com/en-us/library/aa337545.aspx
MatthewMartin
Believe or not, I think I was using the wrong password the whole time. I went back in and changed the password with the enforced password policy box unchecked. My connection and edits to sql now work. Thanks for the help.
dan_vitch
A: 

As indicated, your connection string does not look correct. You can find examples at connectionstrings.com. Alternatively, this KB article may be of some help.

Garett