看看这段转换代码为什么越跑越慢啊?
public partial class RunWebIDApp : Form
{
public RunWebIDApp()
{
InitializeComponent();
}
private void btn_run_Click(object sender, EventArgs e)
{
IList <myApp> list = new List <myApp> ();
SqlConnection conn = new SqlConnection( "server=.;uid=xiaoyi;pwd=123;database=CNKI ");
SqlCommand comm = new SqlCommand( "select svrUrl,svrAutoID from svr_Info ", conn);
conn.Open();
using (SqlDataReader rdr = comm.ExecuteReader())
{
while (rdr.Read())
{
myApp app = new myApp();
app.url = rdr.GetString(0);
app.autoID = rdr.GetInt32(1);
list.Add(app);
}
}
foreach (myApp myapp in list)
{
comm.CommandText = string.Format( "update classLink set webID={0} where svrUrl= '{1} ' ", myapp.autoID, myapp.url);
int i = comm.ExecuteNonQuery();
this.tbx_show.Text += myapp.url + "==> " + i.ToString();
this.tbx_show.Focus();
this.tbx_show.Select(this.tbx_show.TextLength, 0);
this.tbx_show.ScrollToCaret();
Application.DoEvents();
}
conn.Close();
MessageBox.Show( "OK,Done! ");
}
}
public struct myApp
{
public string url;
public int autoID;
}
list有2000多条数据
classLink表中有8000多数据
按说应该跑的很快的呀
怎么越跑越慢,到现在2秒动一下
程序有什么问题?大虾给看看
[解决办法]
学习
[解决办法]
我不是大虾,我不会解决。
[解决办法]
每1000个update组合(连接)为一个SQL。