using (OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=msg.mdb"))
{
cn.Open();
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
XmlDocument xml = new XmlDocument(); //装载XML数据
xml.InnerXml = sbuf.ToString();
XmlNodeList xn = xml.GetElementsByTagName("message");
foreach (XmlElement xe in xn)
{
cmd.CommandText = string.Format(
"INSERT INTO inbox([msgid],[teacher],[content],[msgdate],[userid]) VALUES ('{0}', '{1}', '{2}', '{3}','{4}')",
xe.ChildNodes[0].InnerText.Trim(),
xe.ChildNodes[1].InnerText.Trim(),
xe.ChildNodes[2].InnerText.Trim(),
xe.ChildNodes[3].InnerText.Trim(),
username
);
cmd.ExecuteNonQuery();
}
}
cn.Close();
}
没有评论:
发表评论