标签:mini count 路径 port dmi ati 界面 datarow insert
大致写写思路,因为sqlserver提供了可以直接导入的图形界面。
1、private static string GetConnectionString(string folderPath) //文件夹路径
{
string connectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+folderPath+@"\;Extended Properties=‘Text;‘";
return connectionString;
}
2、string sql="select from 1.csv";
DataTable dt=OleDbHelper.Query(@"C:\Users\Administrator\Desktop",sql);
StringBuilder sb=new StringBuilder();
string portCode=string.Empty;
string nameCode=string.Empty;
if(dt!=null&&dt.Rows.Count>0)
{
foreach(DataRow dr in dt.Rows)
{
portCode=dr["portCode"].ToString();
nameCode=dr["nameCode"].ToString();
sb.AppendLine("insert into TableName (portCode,nameCode) values(‘"+portCode+"‘,‘"+nameCode+"‘)");
}
string result=sb.ToString();
}
DbHelper.ExecuteSql(result);
标签:mini count 路径 port dmi ati 界面 datarow insert
原文地址:http://www.cnblogs.com/sunice/p/6375975.html