转换DataSet到普通xml的新法
来源:互联网 发布:无权限访问网络打印机 编辑:程序博客网 时间:2024/04/29 19:45
方法一:
Public Class DataSetToxml : Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objConn As SqlConnection
Dim strSql As String
strSql = "SELECT TOP 10 * FROM Customers"
objConn = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet()
sdaCust.Fill(dstCust, "Customers")
'Save data to xml file and schema file
dstCust.Writexml(Server.MapPath("Customers.xml"),xmlWriteMode.IgnoreSchema)
dstCust.WritexmlSchema(Server.MapPath("Customers.xsd"))
End Sub
这种方法是写入一个xml文件
方法二:
<WebMethod(Description:="所有教室列表")> _
Public Function ListAllRooms() As xmlDocument
Try
m_CpCourseArrange.FillRoomId(m_DsCourseArrange)
'Dim reader As New MemoryStream
Dim doc As New xmlDocument
doc.Loadxml(m_DsCourseArrange.Getxml.ToString)
Return doc
Catch ex As Protocols.SoapException
Throw SoapExceptionE.RaiseException("ListAllRooms", "http://tempuri.org/CourseArrange", ex.Message, "4000", ex.Source, SoapExceptionE.FaultCode.Server)
End Try
End Function
Getxml--Returns the xml representation of the data stored in the DataSet. (MSDN)
Private Shared Sub DemonstrateGetxml()
' Create a DataSet with one table containing two columns and 10 rows.
Dim ds As DataSet = New DataSet("myDataSet")
Dim t As DataTable = ds.Tables.Add("Items")
t.Columns.Add("id", Type.GetType("System.Int32"))
t.Columns.Add("Item", Type.GetType("System.String"))
' Add ten rows.
Dim r As DataRow
Dim i As Integer
For i = 0 To 9
r = t.NewRow()
r("id") = i
r("Item")= "Item" & i
t.Rows.Add(r)
Next
' Display the DataSet contents as xml.
Console.WriteLine( ds.Getxml() )
End Sub
- 转换DataSet到普通xml的新法
- 转换DataSet到普通xml的新法
- ASP.net:转换DataSet到普通xml的新法
- 转换DataSet到普通xml
- DataSet到XML的转换函数
- 将多个DataTable添加到指定的DataSet中,转换DataSet为XML,将DataTable转换XML
- DataSet转换XML转换DataSet
- XML与DataSet的相互转换类
- XML与DataSet的相互转换类
- xml格式的string转换为dataset
- xml与DataSet的互转换类
- XML与DataSet的相互转换类
- xml与DataSet的互转换类
- DataSet与Xml之间的转换
- XML与DataSet的相互转换类
- XML与DataSet的相互转换类
- XML与DataSet的相互转换类
- XML与DataSet的相互转换类
- 去除隔间,增进沟通
- ASP.NET创建Web服务之使用事务
- ASP.NET提供文件下载函数
- ASP.net生成文字图片
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 转换DataSet到普通xml的新法
- 如何显示在线人数和所在位置
- asp.net实现C#代码加亮显示
- ASP.NET中使用数据处理插入数据注意的问题
- 如何取得IP/用户名等信息
- ASP.NET热点问题解答14个
- ASP.NET中如何防范SQL注入式攻击
- 原创的自定义分页UserControl分享及探讨
- 如何在上传的图片上写字