Total Page Preview:   000000000221

Explain connection string and web config. in ASP.NET in English and Hindi

 

 Connection string and web config. in ASP.NET in Engilsh 

A connection string is a set of parameters or information used to connect to a database from an application. In ASP.NET, the connection string is used to specify the details of the SQL Server database to which the application needs to connect. It contains information like the name of the server, database name, username, password, and other parameters needed to establish the connection.

A web.config file is an XML configuration file that is used to store application-level settings and configuration information in ASP.NET applications. It contains settings for the entire application, including the connection string used to connect to the SQL Server database.
Here's an example of a connection string and web.config file:
Connection string:
In this example, the connection string is named "MyConnectionString". It contains the following parameters:
  • Data Source: The name of the server where the SQL Server database is located
  • Initial Catalog: The name of the database to which the application should connect
  • User ID: The username used to authenticate with the SQL Server database
  • Password: The password used to authenticate with the SQL Server database
Web.config file:
<?xml version="1.0"?>
<configuration>
  <connectionStrings>
      <add name="MyConnectionString" connectionString="Data Source=MyServerName;Initial Catalog=MyDatabaseName;
                             User ID=MyUsername;Password=MyPassword" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
 
In this example, the web.config file contains a <connectionStrings> section that specifies the connection string with the name "MyConnectionString". The connectionString attribute contains the actual connection string, and the providerName attribute specifies the ADO.NET data provider that should be used to connect to the database.
 
The connection string and web.config file are important parts of an ASP.NET application, as they provide a central place to store the database connection information and other configuration settings that the application needs to run. By using a web.config file, you can easily modify the application settings without having to modify the application code itself.
 
 
 
 

Connection string and web config. in ASP.NET in Hindi

Connection string aur web.config dono hi asp.net mein application aur database ke beech ek connection establish karne ke liye bahut zaroori hote hain.
Connection string ek set of parameters hai jo database ke saath connection establish karne ke liye upyog kiya jaata hai. Ye parameters database ke server name, database name, username, password, aur other connection related settings jaise ki connection timeout, pooling, encryption, etc. ko define karte hain.
 
Web.config file ek XML file hai, jisme application-level settings aur configurations store kiye jaate hain. Ye file asp.net application ke entire settings ko store karti hai, jisme se ek setting connection string hai. Web.config file ek centralized configuration store ka kaam karta hai, jiske dwara application ke settings ko easily modify aur manage kiya ja sakta hai.
Yahaan ek connection string aur web.config ka example diya gaya hai:
Connection string example:
Is connection string mein "MyConnectionString" naam ka ek connection string define kiya gaya hai. Ismein connectionString attribute mein server name, database name, username, password, aur integrated security ka status define kiya gaya hai. Is connection string ke dwara asp.net application SQL Server database se connect kar sakta hai.
 
Web.config example:
<?xml version="1.0"?>
<configuration>
  <connectionStrings>
      <add name="MyConnectionString" connectionString="Data Source=MyServerName;Initial Catalog=MyDatabaseName;
                             User ID=MyUsername;Password=MyPassword" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
 
Is web.config example mein, <connectionStrings> section mein "MyConnectionString" naam se ek connection string define kiya gaya hai. Ismein connectionString attribute mein server name, database name, username, password, aur integrated security ka status define kiya gaya hai, aur providerName attribute mein data provider ka naam specify kiya gaya hai.
 
Jab asp.net application run hoti hai, tab ye web.config file ka upyog karta hai aur connection string ko retrieve karke SQL Server database se connect ho jaata hai. Ye ek centralized approach hai jiske dwara hum asp.net application ke saare connection strings ko ek hi jagah manage aur modify kar sakte hain.

 

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: