//创建并创建50条数据 static void CreateTableAndData() { using (XmlTable xt = new XmlTable()) //这一行会自动创建表结构 { bool result = xt.Delete("0=0"); //清空所有数据。 OutMsg("Delete 所有: - " + result); for (int i = 1; i < 60; i++) { xt.Name = "Name" + i.ToString(); xt.DateTime = DateTime.Now.AddSeconds(i); xt.Insert(); } } }
static void Start() { int rndNum = DateTime.Now.Second;//随机数 using (XmlTable xt = new XmlTable()) { if (xt.Fill(rndNum))//查询 { OutMsg("Fill:" + rndNum); xt.Name = xt.Name + "_N"; bool result = xt.Update(); OutMsg("Update:" + rndNum + " - " + result); } rndNum = rndNum + 1; if (xt.Exists(rndNum)) { OutMsg("Exists:" + rndNum); bool result = xt.Delete(rndNum); OutMsg("Delete:" + rndNum + " - " + result); } } }