利用DataSet对Xml文件操作
-----------------------------------------------
将DataSet内容写入Xml文件
-----------------------------------------------
Dim connstr As String = "数据库连接字符串"
Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connstr)
Dim sqlstr As String = "SQL语句"
Dim MyDataAdapter As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(sqlstr, conn)
Dim MyDataSet As Data.DataSet = New Data.DataSet
MyDataAdapter.Fill(MyDataSet, "数据库表名")
MyDataSet.WriteXml(Server.MapPath("Xml文件相对路径"))
Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connstr)
Dim sqlstr As String = "SQL语句"
Dim MyDataAdapter As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(sqlstr, conn)
Dim MyDataSet As Data.DataSet = New Data.DataSet
MyDataAdapter.Fill(MyDataSet, "数据库表名")
MyDataSet.WriteXml(Server.MapPath("Xml文件相对路径"))
-------------------------------------------------------------
DataSet读取Xml文件内容并绑定控件
--------------------------------------------------------------
Dim myDataSet As Data.DataSet = New Data.DataSet()
myDataSet.ReadXml(Server.MapPath("test.xml"))
GridView1.DataSource = myDataSet
GridView1.DataBind()
myDataSet.ReadXml(Server.MapPath("test.xml"))
GridView1.DataSource = myDataSet
GridView1.DataBind()