Exportar archivo a una ubicacion especifica
Publicado por Oscar (31 intervenciones) el 09/04/2018 19:13:51
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
70
71
72
73
74
75
76
If iva = 0 Then
'Try
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 = " + "'" + patente.Text + "'" + " + " + "'" + Numpedimento.Text + "'" + ",GPO = " + "'" + gpototal.Text + "'" + ",CON = " + "'" + contotal.Text + "'" + ",CantidadD,UM,importeunitario = " + "'" + Imp.Text + "'" + ",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)
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 As Integer = 0 To dt.Rows.Count - 1
'Response.Write("<script>alert('Conexion realizada');</script>")
'Conexion.Text = (dt.Rows(i).Item(0) & " Conexion realizada " & dt.Rows(i).Item(1))
'Conexion.Text = "Conexion realizada"
'Response.Write("<script>alert('Conexion realizada');</script>")
'MsgBox(dt.Rows(i).Item(0) & " Conexion realizada " & dt.Rows(i).Item(1))
Next
Response.Clear()
Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename= " + "'" + pedimentoherdez.Text + "'" + " ")
'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()
' Catch ex As Exception
' MsgBox("Can not open connection ! ")
'End Try
End If
Hola quisiera sugerencias sobre que podria hacer al exportar el archivo csv que caiga en una cierta carpeta anteriormente especificada
gracias de antemano por el apoyo
Valora esta pregunta


0