读取txt文档
string path = Server.MapPath("~\\BasicData\\"+name+".txt");
StreamReader sr = new StreamReader(path, System.Text.Encoding.GetEncoding("gb2312"));
String line;
if(name=="仓位" || name=="存储类型")
{
while ((line = sr.ReadLine()) != null) //取单行
{
string[] arrVal = line.Split('\t');
string code, description,warehouse;
code = arrVal[0].ToString();
description = arrVal[1].ToString();
warehouse=arrVal[2].ToString();
strsql="insert into "+tablename+"(Code,Description,warehouse) values('"+code+"','"+description+"','"+warehouse+"')";
cm.CommandText=strsql;
cm.Connection=cn;
cm.ExecuteNonQuery();
}
}