Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear programmer,

I have backuped my sql database and restored on another computer. Now when I try to login to it programatically using C# I get error: "Login failed for user 'new computer name'".
I am using windows authentication and my connection string looks like this:
Data Source=.\\sqlexpress;Initial Catalog="office_ session";Integrated Security=True

when I try Visual studio -> server explorer -> connect to a database wizard
everything works fine.

Thank you for your time
Posted
Comments
[no name] 10-May-11 5:28am    
you need to show your code.

did you try to connect it in SQL Management Studio? And did you already check your sql configuration?
 
Share this answer
 
Comments
oentezari 10-May-11 5:22am    
Actually the new computer has no management studio.
But as I mentioned visual studio connection wizard produces the same
string and connects perfectly.
thank you
In order to know what is the connection string create a text file and change the extension of it to udl eg:ConnectionString.udl and click on it you will see a dialog now do the settings once you have done the settings test the

connection and then click on OK

Now right click the ConnectionString.udl file and open it with notepad you will get the connection string
 
Share this answer
 
Integrated Security in the connection string[^] tell to use the current Windows account credentials for authentication. You have to change some security settings for SQL Express.
And running you program as a service or under Visual Studio is not the same.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900