After the for loop is complete, close the database connection. This reduces resource consumption. Although Close is not immediately closed, it is resource-consuming to obtain a connection from the connection pool. Use the parameter method as much as possible to reduce the usage of dbservercpu, because SQL does not need to be compiled repeatedly. The approximate code is as follows: using (varconnewConnection ()){
After the for loop is complete, close the database connection. This reduces resource consumption. Although Close is not immediately closed, it is resource-consuming to obtain a connection from the connection pool. Use the parameter method as much as possible to reduce the cpu usage of dbserver, because SQL does not need to be compiled repeatedly. The approximate code is as follows: using (var con = new Connection ()){
After the for loop is complete, close the database connection. This reduces resource consumption. Although Close is not immediately closed, it is resource-consuming to obtain a connection from the connection pool. Use the parameter method as much as possible to reduce the cpu usage of dbserver, because SQL does not need to be compiled repeatedly. The Code is as follows:
Using (var con = new Connection ())
{
Var command = // create a Parameter list and SqlCmmand
For (int I = 0; I < p><>
{
// Return the Value to commnad.parameters.
Command.exe cute ()
}
}
Of course there are other optimization methods, but at least we need to do the above.