第1个回答 2013-06-07
private void button1_Click(object sender, EventArgs e) { string path = null; OpenFileDialog op = new OpenFileDialog();//实例openfiledialog op.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (op.ShowDialog() == DialogResult.OK)//选则文件 { path = op.FileName;//获取文件路径 } if (path != null) { using (StreamReader sr = new StreamReader(path, Encoding.Default)) { String line; while ((line = sr.ReadLine()) != null) { string[] rowtext = line.Split(",".ToCharArray()); String sql = “insert into 表 (列1,列2) Values(rowtext[0].Tostring(),rowtext[1].Tostring())” } } } }