No matter what I try I keep getting the following error when I try to run a simple select query to the database I created (I’ve run the exact query in the Management studio and it works fine and the login used is in the sysadmin group):
{“Cannot open database \”Test\” requested by the login. The login
failed.\r\nLogin failed for user
‘JackLarson’.”} System.SystemException
{System.Data.SqlClient.SqlException}
My connection string is:
Data Source=.\MPIT_TEST;Initial Catalog=Test;Integrated
Security=True;Connect Timeout=30;User Instance=True
you have to set your server name in your connection string
if your servername is SERVERSQLCOMPUTER your connection string will be:
Moreover, always specify server name to be able to use your application on every computer in network entreprise (servername\serverinstance is an absolute path)
.\serverinstance means that your application is on the same computer than your Sql server