byte[] byData = new byte[100];char[] charData = new char[1000]; string path = "F:\\小說(shuō)\\新建文本文檔 (2).txt"; read(path);
private static void read(string path)//分讀取2,讀取所有字符 { StreamReader sr = new StreamReader(path, Encoding.Default); string line=""; int judge = 0; while ((line = sr.ReadLine()) != null) { if (line == "") { continue; } Console.WriteLine(line.ToString()); string sql = string.Format("insert into data values('{0}')", line); int r = DBhelp.ExecuteNonQuery(sql); if (r > 0) { judge++; } } if (judge > 0) { System.Windows.Forms.MessageBox.Show("添加成功", "添加成功消息"); } }
- 2 回答
- 0 關(guān)注
- 537 瀏覽
添加回答
舉報(bào)
0/150
提交
取消