Close

Connecting Microsoft SQL Server Database in .NET Framework Web Application

While using MSSQL Server with .Net Framework, to connect with database use these simple steps.

In Web.Config File (Using LocalDb) :

<connectionStrings>
    <add name="OnlineTicketingSystem" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=OnlineTicketingSystemDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

In Web.Config File (Using Local) :

<connectionStrings>
    <add name="OnlineTicketingSystem" connectionString="Data Source=(Local);Initial Catalog=OnlineTicketingSystemDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

In DbContext :

public OnlineTicketingSystemContext() : base("OnlineTicketingSystem")
        {}

Leave a Reply

Your email address will not be published. Required fields are marked *