就是运行到最后的MessageBox的时候出现
这是怎么回事,关于关闭的,请详细解释一下,谢谢!!
private void button1_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "文本文件|*txt";
if (ofd.ShowDialog() != true)
{
return;
}
string filename = ofd.FileName;
IEnumerable<string> lines = File.ReadLines(filename, Encoding.Default);
foreach (var line in lines)
{
string[] segs = line.Split('|');
string name = segs[0];
string age = segs[1];
SqlHelper.ExecuteNonQuery("insert into tbl_Import (Name,Age) values(@Name,@Age)",
new SqlParameter("@Name", name),
new SqlParameter("@Age", Convert.ToInt32(age)));
}
MessageBox.Show("成功导入" + lines.Count() + "条数据");
}
|