0

I am developing mvc 4 projects and when I use the following connection string it works:

<add name="name" 
 connectionString="Server=.\sqlexpress;Database=dbname;
 Trusted_Connection=true;" 
 providerName="System.Data.SqlClient"/>

But when I add a username and password to this project, I can't connect to my database. I added the user credentials correctly. I have db_owner permission for this database, and in my database everything is correct. The connection string below does not work:

  <add name="DocContext"
   connectionString="Server=.\sqlexpress;Database=DocContext;
   User ID=pooria;Password=19216801;Trusted_Connection=false;"   
   providerName="System.Data.SqlClient"/>
Appulus
  • 18,630
  • 11
  • 38
  • 46
Pnsadeghy
  • 1,279
  • 1
  • 13
  • 20

1 Answers1

1

Connection String You are using follows format -

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;

Try using IP Address, Port in Data Source field like -

<connectionStrings>
    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=190.190.200.100,1433;
                          Initial Catalog=MyDatabaseName;
                          Integrated Security=False;
                          User ID=MyUserID;Password=MyPassword;
                          MultipleActiveResultSets=True" />
  </connectionStrings>

And the following link may help you LINK

Community
  • 1
  • 1
sareeshmnair
  • 441
  • 1
  • 6
  • 18