Mining web site, the Web site changes every day, and the database has thousands of data, through the Select COUNT (*) to find the database there is no such URL, do not have to collect storage, so if the Web page update 1000 connections, the acquisition will be select COUNT (*) 1000 times, 1 times Select COUNT (*) to compare thousands of data in the database, so the speed is slow, like in the code below the cmdlist. ADD ("update newsandnotice Set id =" + i + "where ID =" + newsid[i] + ";"); method, once all query statements are added to the array, one-time query, once back to the results of each query!
//string SQL = "SELECT count (*) from News where ss= ' web address '"; //list<string> NewsID = sql_hp. Sql_column (SQL);List<string> cmdlist =Newlist<string>(); Cmdlist. ADD ("BEGIN;"); for(inti =0; i < Newsid.count; i++) {cmdlist. ADD ("Update News Set ID ="+ i +"WHERE ID ="+ Newsid[i] +";"); } cmdlist. ADD ("COMMIT;"); SQL_HP. Sql_insert (cmdlist); Public intSql_insert (list<string>Cmd) {intTempint =0; while(!Connopen ()) Thread.Sleep ( -); Sqlitecommand Command=NewSqlitecommand ("", conn); foreach(stringIinchCmd.toarray ()) {Command.commandtext=i; Try{command. ExecuteNonQuery (); } Catch{}} command. Dispose (); Connclose (); returnTempint; }
SQLite database Query Batch