c# 从XML读数据
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this.DropDownList1.DataValueField = "value";
this.DropDownList1.DataBind();
XML
<?xml version="1.0" encoding="utf-8" ?>
<selects>
<select>
<text>国家级</text>
<value>1</value>
</select>
<select>
<text>省级</text>
<value>2</value>
</select>
<select>
<text>市级</text>
<value>3</value>
</select>
</selects>
相关文档:
在项目中,我们很多都用到了xml文件,无论是参数配置还是与其它系统的数据交互。
今天就来讲一下Java 中使用dom4j来操作XML文件。
我们需要引入的包:
//文件包
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//工具包
import java.util.Itera ......
SQL中有四种基本的DML操作:INSERT,SELECT,UPDATE和DELETE。
INSERT语句
用户可以用INSERT语句将一行记录插入到指定的一个表中。例如,要将雇员John Smith的记录插入到本例的表中,可以使用如下语句:
INSERT INTO EMPLOYEES VALUES
('Smith','John','1980-06-10',
'Los Angles',16,45000);
......
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person id="1">
<username >xiaoma</username>
<password>xiaoma</password>
</person>
<person id="2">
<username>manager</username> ......
(一) 先讲一下XML中的物殊字符,手动填写时注意一下。
字符 字符实体
& ......
连接sql server数据库用到的命名空间是using System.Data.SqlClient;
数据库连接代码:可以在大类之下声明 public SqlConnection myConnection; //sql连接对象
&nbs ......