2006-11-11
ASP2.0 DataSet 匯出XML文件
Dim connString As String = ConfigurationManager.ConnectionStrings("DBConnectionString").ConnectionString
Dim con As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connString)
Dim strsql As String = "select * from dbtable"
Dim adapter As New Data.SqlClient.SqlDataAdapter(strsql, con)
Dim ds As New System.Data.DataSet()
adapter.Fill(ds)
Dim xmlFile As String = "new.xml"
' 建立StreamWriter物件
Dim sw As IO.StreamWriter = New IO.StreamWriter(Server.MapPath(xmlFile))
' 寫入XML文件
ds.WriteXml(sw)
sw.Close()
Dim con As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connString)
Dim strsql As String = "select * from dbtable"
Dim adapter As New Data.SqlClient.SqlDataAdapter(strsql, con)
Dim ds As New System.Data.DataSet()
adapter.Fill(ds)
Dim xmlFile As String = "new.xml"
' 建立StreamWriter物件
Dim sw As IO.StreamWriter = New IO.StreamWriter(Server.MapPath(xmlFile))
' 寫入XML文件
ds.WriteXml(sw)
sw.Close()