Saturday, October 23, 2021

Solve Error Login Failed for User in C# and SQL

 This is the Common Problem we are facing in Server DB Connection in Asp.net.If you are using windows authentication to connect to the Server DB, you need to set "Trusted_Connection=True;" if you are using SQL server authentication, you need to declare User "Id=myUsername; Password=myPassword;"

 
Code Snippet In Web.Config: 
 
Windows authentication 
  1. <add name="windowsConnection" connectionString="Server=localhost; Database=databasename; Trusted_Connection=True;" />  
SQL server authentication 
  1. <add name="Sqlserverconnection" connectionstring="server=localhost; Database=databasename;uid=db; password=123 "/>  

No comments:

Post a Comment

No String Argument Constructor/Factory Method to Deserialize From String Value

  In this short article, we will cover in-depth the   JsonMappingException: no String-argument constructor/factory method to deserialize fro...