Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/02/2009, 12:24
Avatar de dadabit
dadabit
 
Fecha de Ingreso: febrero-2009
Ubicación: Coahuila, México
Mensajes: 145
Antigüedad: 16 años
Puntos: 1
Respuesta: problema al generar XML

bueno nadie me contesto, pero ya encontre la solución

Código VB:
Ver original
  1. 'Lee y construye un XML a partir de la tabla customers de NorthWind
  2.        Dim ds As New DataSet
  3.         Dim path = Server.MapPath("~/customers.xml") 'ubicación donde se guarda archivo, carpeta del proyecto
  4.        Try
  5.             'Cambiar Server:
  6.            Using conn As New SqlConnection("Server=dadabit\sqlexpress;integrated security=true;database=Northwind;uid=sa;pwd=;")
  7.                 Dim command As New SqlCommand("select * from customers", conn)
  8.                 conn.Open()
  9.                 ds.DataSetName = "Customers"
  10.                 ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "customers")
  11.                 ds.WriteXml(path, XmlWriteMode.IgnoreSchema) 'escribe archivo XML sin schema
  12.                Response.ContentType = "text/xml"
  13.                 ds.WriteXml(Response.OutputStream) ' escribe resultado en pantalla
  14.            End Using
  15.             MsgBox("XML de customers creado")
  16.         Catch excepcion As SqlException
  17.             MsgBox("Ocurrio una Excepción en la conexión")
  18.         End Try