2013-06-27
展开全部
现在的兄弟不负责解释 老说一点点
这是我的一个实例 你看看吧 对应该有帮助
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();
这是我的一个实例 你看看吧 对应该有帮助
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();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-27
展开全部
public string GetXmlDocument(string xmlFilePath)
{
string doc = string.Empty;
XmlTextReader xtr = new XmlTextReader(xmlFilePath);
while (xtr.Read())
{
doc += xtr.ReadInnerXml();
}
return doc;
}
写入应该很简单了吧... 自己想办法吧..^_^
{
string doc = string.Empty;
XmlTextReader xtr = new XmlTextReader(xmlFilePath);
while (xtr.Read())
{
doc += xtr.ReadInnerXml();
}
return doc;
}
写入应该很简单了吧... 自己想办法吧..^_^
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-07-11
展开全部
----导入xml文件DECLARE@idocintDECLARE@docvarchar(1000)--sampleXMLdocumentSET@doc='CustomerwasverysatisfiedImportantHappyCustomer.'--CreateaninternalrepresentationoftheXMLdocument.EXECsp_xml_preparedocument@idocOUTPUT,@doc--ExecuteaSELECTstatementusingOPENXMLrowsetprovider.SELECT*FROMOPENXML(@idoc,'/root/Customer/Order',1)WITH(oidchar(5),amountfloat,commentntext'text()')EXECsp_xml_removedocument@idoc
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-27
展开全部
怎样用XmlTextreader解析xml文档
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询