Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/02/2009, 09:38
Avatar de dadabit
dadabit
 
Fecha de Ingreso: febrero-2009
Ubicación: Coahuila, México
Mensajes: 145
Antigüedad: 15 años, 3 meses
Puntos: 1
Respuesta: Generar Archivo Plano en VB.net

yo estoy creando xml, solo que utilizo sqlServer...pero te paso el codigo..ajola y te sirva..
tambien te pone la info en un grid

necesitas de las librerias de:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml

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

y listo...espero que aya sido de ayuda