Error al exportar a CSV
Publicado por Oscar (31 intervenciones) el 28/03/2018 21:07:10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
If iva = 0 Then
connetionString = "Data Source=DESKTOP-LD02VBB;Initial Catalog=SIR;Persist Security Info=True;User ID=sa;Password=123"
firstSql = " Select cia = " + "'" + Cia.Text + "'" + ",suc = " + "'" + Suc.Text + "'" + ",dep = " + "'" + Dep.Text + "'" + ",tipos,folio,usuarioas400,Descripcion,proveedor1,FechaDoc = " + "'" + FechaDoc + "'" + ",id_prov_Hdz = " + "'" + Prov.Text + "'" + ",tipodemoneda " &
" ,Serie,Numero,GPO = " + "'" + gpototal.Text + "'" + ",CON = " + "'" + contotal.Text + "'" + ",CantidadD,UM,importeunitario,Importe = " + "'" + Imp.Text + "'" + ",estatusse,FolioSe,estatusdecarga,estatusdeaprobacion,Error,usuariodetransmision,pcqueenviadatos " &
",programa" &
",FechaCaptura = " + "'" + FechaCaptura + "'" + ",HoraCaptura = " + "'" + HoraCaptura + "'" + " " &
"From [SIR].[SIR].[SIR_60_REFERENCIAS] " &
" Left Join [dbo].[ClientesHerdez] As CH On [SIR].[SIR].[SIR_60_REFERENCIAS].nIdImex07 = CH.id_sclave_reco " &
"Left Join [SIR].[SIR].[SIR_188_FACTURAS_REFERENCIAS] As FAC On [SIR].[SIR].[SIR_60_REFERENCIAS].nIdReferencia60 = FAC.nIdReferencia60 " &
"Left Join [SIR].[SIR].[SIR_52_FACTURAS] As FA On FAC.nIdFactura52 = FA.nIdFactura52 " &
"Left Join [dbo].[Prov_Herdez]As PH On FA.nIdProveedor42 = PH.id_prov_reco " &
"LEFT JOIN [SIR].[Admin].[SIR_VT_Sabana_PedimentoMarcos] as SB ON [SIR].[SIR].[SIR_60_REFERENCIAS].nIdReferencia60 = SB.ID " &
" where [sReferencia] = " + "'" + TextBoxReferencia.Text + "'" + " "
secondSql = ""
connection = New SqlConnection(connetionString)
Try
connection.Open()
command = New SqlCommand(firstSql, connection)
adapter.SelectCommand = command
adapter.Fill(ds, "Table(0)")
adapter.Dispose()
command.Dispose()
connection.Close()
dt = ds.Tables(0)
For i = 0 To dt.Rows.Count - 1
MsgBox(dt.Rows(i).Item(0) & " -- " & dt.Rows(i).Item(1))
Next
Catch ex As Exception
'MsgBox("Can not open connection ! ")
End Try
Response.Clear()
Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename=Herdez.csv")
Response.ContentType = "application/text"
Dim sb As New StringBuilder()
'For k As Integer = 0 To dt.Columns.Count - 1
'add separator
'sb.Append(dt.Columns(k).ColumnName + ","c)
'Next
'append new line
'sb.Append(vbCr & vbLf)
For i As Integer = 0 To dt.Rows.Count - 1
For k As Integer = 0 To dt.Columns.Count - 1
'add separator
sb.Append(dt.Rows(i)(k).ToString().Replace(",", ";") + ","c)
Next
'append new line
'sb.Append(vbCr & vbLf)
Next
Response.Output.Write(sb.ToString())
Response.Flush()
Response.End()
End If
Cuando lo hago desde mi servidor me exporta el CSV adecuadamente sin ningun error
adjunto dos imagenes de la forma correcta cuando se exporta.


Ahora ya pasada toda la informacion en el servidor este es el error que me muestra la diferencia que me doy cuenta es que nisiquiera me abre el cuadro con el mensaje en forma de icono nose si sea ahi el problema.

Si tienen alguna sugerencia de a que se podria deber este problema estare muy agradecido
Saludos y gracias por la atencion.
Valora esta pregunta


0