将文本文件内容导到SQL Server中 我现在从文本文件中获得相关数据,并导入到一个DataTable中,那种方法能比较好的把这些数据插入到一个SQL Server的表中呢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static string ReadTxt() { StreamReader inStr = null; string str = string.Empty; FileInfo textFile = new FileInfo(@"C:\test.txt"); inStr = textFile.OpenText(); //Console.WriteLine("\n Reading from text file: \n"); string textLine = inStr.ReadLine(); while(textLine != null) { str = str + "\n\r" + textLine; textLine = inStr.ReadLine(); //在这里插入数据库 } inStr.Close(); return str; } 最好是手工用SQL SERVER的导入向导,效率比你用代码快10倍. :) 问个窗体布局的问题 使用正则处理字符串!急!! 急需大神来帮助! 一个简单的登录程序 C#串口通讯 搞不懂的一个小问题?c#2005.................................. 分段读文件问题,总是超过范围,请指教 b/s与c/s 如何遍历tabcontrol里的控件? 打开文件对话框的问题 急急…………………… 窗体注销? 超级难度 《DataGridView问题:如何在DataGridView中添加一个合计行》,高手请进
{
StreamReader inStr = null;
string str = string.Empty;
FileInfo textFile = new FileInfo(@"C:\test.txt");
inStr = textFile.OpenText();
//Console.WriteLine("\n Reading from text file: \n");
string textLine = inStr.ReadLine();
while(textLine != null)
{
str = str + "\n\r" + textLine;
textLine = inStr.ReadLine();
//在这里插入数据库
}
inStr.Close();
return str;
}
最好是手工用SQL SERVER的导入向导,效率比你用代码快10倍. :)