|02|Sofia||Lopez|Nuñez|12/12/2013|
|03|Alejandro||Quiróz|Chávez|10/12/2013|
|04|Rosa||Ramirez|Pérez|10/12/2013|
y como tendría que quedar
|01|Oscar||Moreno|Alvarez|13/12/2013|
|02|Sofia||Lopez|Nuñez|12/12/2013|
|03|Alejandro||Quiróz|Chávez|10/12/2013|
|04|Rosa||Ramirez|Pérez|10/12/2013|
acá esta el código
Código:
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cn As New SqlConnection("Server=OMORENO;Database=DBVentas;Integrated Security=True;")
Dim cmd As New SqlCommand("TraerDatos", cn)
Dim dr As SqlDataReader
cn.Open()
Try
cmd.CommandType = CommandType.StoredProcedure
dr = cmd.ExecuteReader()
Dim strStreamW As Stream
Dim strStreamWriter As StreamWriter
dr.Read()
Dim FilePath As String = "C:\Users\Oscar Moreno\Desktop\prueba.txt"
strStreamW = File.OpenWrite(FilePath)
strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.UTF8)
'AGREGANDO LA INFORMACION
While dr.Read()
strStreamWriter.WriteLine("|" & CStr(dr("DNIUsuario")) & "|" & campo1 & "||" & (CStr(dr("ApellidoPaterno"))) & "|" & (CStr(dr("ApellidoMaterno"))) & "|" & (CStr(dr("FechaNacimimento"))) & "|")
End While
strStreamWriter.Close()
dr.Close()
cn.Close()
Catch ex As Exception
MsgBox(ex.Message.ToString)
cn.Close()
End Try
End Sub
End Class
Cualquier ayuda será muy valiosa, saludos.