In the web. in the config configuration file, the first step is to connect to the database: in the web. the following code adds underscores in the config configuration file: <configuration> <connectionStrings> <add name = "SQL" connectionString = "server = localhost; database = dbo. tab_ManagerInfo; userid = sa; pwd = abc123 "providerName =" System. data. sqlClient "/> </connectionStrings> <system. web> <compilation debug = "false" targetFramework = "4.0"/> </system. web> </configuration> Step 2: Introduce the using System on the page for database connection. configuration; // when setting the database connection in the Configuration file, you must use Step 3: public partial class Login: System at the beginning of the page. web. UI. page {public static string constr = ConfigurationSettings. appSettings ["SQL"]; // "SQL" is step 4 of add name = "SQL"} in the configuration file: use the database connection string constr // public static string constr advantages: 1. no need to write the connection string in every page. 2. to port the software or database on each page, you only need to modify the database connection in the configuration file.