把我们写SQL的mapper.xml文件夹路径配置在Path中,保存。
现在的兄弟不负责解释 老说一点点SqlConnection conn = new SqlConnection(EccDBConnstr)
conn.Open()
SqlCommand cmd = new SqlCommand()
cmd.Connection = conn
//插入数据到临时表
string sLine
FileStream fs = new FileStream(path + @"\" + STATFileName, FileMode.Open, FileAccess.Read)
StreamReader sr = new StreamReader(fs,Encoding.GetEncoding("GB2312"))
StringBuilder str = new StringBuilder()
while (sr.Peek() >= 0)
{
sLine = sr.ReadLine()
//忽略表头
if (sLine.Length >0)
{
sLine = sLine.Replace(",", ",")
ArrayList list = GetSplitKeys(sLine, Convert.ToChar(','))
str.AppendLine(" insert into Sub(id,type,BizCode,BizName,Serv_code,OprTime,Region_code,Op_name,Op_number) values('" + list[0] + "','" + list[1] + "','" + list[2] + "',N'" + list[3] + "','" + list[4] + "','" + GetDate(list[5].ToString()) + "','" + list[6] + "',N'" + list[7] + "','" + list[8] + "') ")
}
}
//this.textBox1.Text = str.ToString()
//return
cmd.CommandText = str.ToString()
cmd.ExecuteNonQuery()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)