0

I am trying to connect to a local database but I am having problems with the creation of the connection string.

I found a small program on the internet to test my connection (see screenshot here: http://s21.postimg.org/vlgsq7rw7/image.jpg).

The program shows the connection as successful but when I use this connection string( same input as in the screen shot):

server=FlorinPilca-PC\SQLEXPRESS;database=DynamicWebServices"

I get the exception

Login failed for user".

I tried all the users I could think of but none worked.

Please tell me what am I doing wrong?

Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Florin Pilca
  • 154
  • 1
  • 1
  • 8
  • Check out [my prefered way of creating a usable connection string](http://stackoverflow.com/a/10480011/205233) - it will create a 100% compatible connection string without any 3rd party tools. – Filburt Feb 21 '14 at 13:01
  • Have you tried connecting with 'sa' acoount? – Deepshikha Feb 21 '14 at 13:01
  • I do not know what that client tool is doing, may be it has by default impersonate windows LOGIN and connecting using that. your connection string needs user/pass explicitly or something that tells to connect using impersonated windows authentication. – Anup Shah Feb 21 '14 at 13:03
  • Filburt i tried what you told me and now the error is Message = "Cannot open database \"DynamicWebServices\" requested by the login. The login failed.\r\nLogin failed for user 'IIS APPPOOL\\Serv'." – Florin Pilca Feb 21 '14 at 13:12

2 Answers2

0

Try the following: Data Source=FlorinPilca-PC\SQLEXPRESS;Initial Catalog=DynamicWebServices;User ID=mylogin;password=mypassword;

Paul Lucaciu
  • 134
  • 3
0

you can use if you use windows authentication

server=FlorinPilca-PC\SQLEXPRESS;database=DynamicWebServices;Integrated Security=True;
Akrem
  • 5,033
  • 8
  • 37
  • 64
  • This is the new exception after doing what you told me:Message = "Cannot open database \"DynamicWebServices\" requested by the login. The login failed.\r\nLogin failed for user 'IIS APPPOOL\\Serv'." – Florin Pilca Feb 21 '14 at 13:17
  • @user2761203 you can found the solution of this problem here http://stackoverflow.com/questions/16427300/login-failed-for-user-iis-apppool-myapppool – Akrem Feb 21 '14 at 13:19
  • @user2761203 and http://stackoverflow.com/questions/6915360/exception-when-deploying-to-iis-login-failed-for-user-iis-apppool-defaultapppo – Akrem Feb 21 '14 at 13:20