110,534
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
//string[] str = { "111111111111", "22222222222222223", "33333333333333", "444444444444", "55555555555", "6666666666" };
//Random ro = new Random();
//textBox1.Text = str[ro.Next(str.Length)];
SqlConnection conn = new SqlConnection("SERVER=192.168.24.30;DATABASE=pc;PWD=werrew;UID=sa;");
string[] filesx = System.IO.Directory.GetFiles(Environment.CurrentDirectory, "*.xls");
string ss="";
string mm="";
if(filesx.Length>0)
{
button1.Enabled = false;
ExcelEdit ee=new ExcelEdit();
double nn;
ee.Open(filesx[0]);
SqlCommand cmd = new SqlCommand("select [内容摘要] from anli", conn);
cmd.Connection.Open();
SqlDataReader sdr = cmd.ExecuteReader();
Excel.Worksheet sheetSource = ee.GetSheet("Sheet1");
int sheetRowCount = sheetSource.UsedRange.Rows.Count;
int kk=1;
for (int i = 2; i <= sheetRowCount;i++ )
{
ss = ((Excel.Range)sheetSource.Cells[i, 5]).Text.ToString().Replace(Environment.NewLine, "").Replace("\n", string.Empty).Replace("\r", string.Empty);
while (sdr.Read())
{
mm = sdr[0].ToString().Replace(Environment.NewLine, "").Replace("\n", string.Empty).Replace("\r", string.Empty);
nn=getSimilarity(ss,mm);
if(nn>0.5)
{
listBox1.Items.Add(kk.ToString()+" "+mm);
kk = kk + 1;
break;
}
Application.DoEvents();
}
//getSimilarity
}
cmd.Connection.Close();
ee.Close();
button1.Enabled = true;
}
}
Ping myPing;
myPing = new Ping();
//using (Ping myPing = new Ping())
//{
myPing.PingCompleted += new PingCompletedEventHandler(myPing_PingCompleted);
string pingIP = "192.168." + j.ToString() + "." + i.ToString();
myPing.SendAsync(pingIP, 1000, null);
//}
这个问题 怎么回事我在win7上用using没问题 怎么我到server 2008的系统上就报错误啊 Ping myPing;
myPing = new Ping();
//using (Ping myPing = new Ping())
//{
myPing.PingCompleted += new PingCompletedEventHandler(myPing_PingCompleted);
string pingIP = "192.168." + j.ToString() + "." + i.ToString();
myPing.SendAsync(pingIP, 1000, null);
//}
这段代码 只要加上using我开发环境的电脑没问题 换到别的电脑上就不行直接就死了