日期:2014-05-17 浏览次数:20787 次
private void ImportDataAndInsertData_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog() { Filter = "文本文件|*.txt", Multiselect = false };
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
t = new Thread(new ThreadStart(() =>
{
dt.Start();
Dispatcher.BeginInvoke(new Action(() => { ImportDataAndInsertData.IsEnabled = false; }));
string[] datas = File.ReadAllLines(ofd.FileName,Encoding.Default); //datas.Length大概在500W-800W左右
ofd.Dispose();
string[] newdatas = RemoveDup3(datas); //去掉重复
Dispatcher.BeginInvoke(new Action(() => { txtAllCount.Text = "总行数:" + newdatas.Length; }));
string sql = string.Empty; //拼接sql语句
for (int i = 0; i < newdatas.Length; i++)
{
string[] tempstr = newdatas[i].Replace("----", "∽").Split('∽');
sql += "exec AddData