Ver Mensaje Individual
  #8 (permalink)  
Antiguo 09/04/2013, 02:00
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 11 meses
Puntos: 7
Respuesta: crear una tabla dependiendo de los resultados de un select

Ya he solucionado el tema. Pongo aquí el código por si a alguien le hace falta:
Código vb.net:
Ver original
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         Dim fechaActual As Date
  3.         Dim nombre, email, mesAnterior, fechacompro, anoActual As String
  4.         Dim mesActual As Integer
  5.         'Dim i, j, cuanto As Integer
  6.         'Dim numcells As Integer = 2
  7.         'i = 0
  8.  
  9.         fechaActual = Now.Date
  10.         mesActual = Month(fechaActual)
  11.         anoActual = Year(fechaActual)
  12.  
  13.         If mesActual = 1 Then
  14.             mesAnterior = 12
  15.         Else
  16.             mesAnterior = mesActual - 2
  17.             'mesAnterior = mesActual
  18.         End If
  19.  
  20.         If mesAnterior < 10 Then
  21.             mesAnterior = "0" + mesAnterior
  22.         End If
  23.  
  24.         fechacompro = anoActual + "-" + mesAnterior + "-"
  25.  
  26.         Dim conn As New SqlConnection(WebConfigurationManager.ConnectionStrings("conexionDesa").ConnectionString)
  27.         'Dim comm1 As SqlCommand = New SqlCommand("SELECT COUNT(DISTINCT(email)) " & _
  28.         '                                        "FROM dbo.temp_datosComunesConceptos " & _
  29.         '                                        "WHERE fecha LIKE '" & fechacompro & "%'", conn)
  30.         'Dim reader1 As SqlDataReader
  31.         Dim comm2 As SqlCommand = New SqlCommand("SELECT DISTINCT(email), nombreApellidos " & _
  32.                                                 "FROM dbo.temp_datosComunesConceptos " & _
  33.                                                 "WHERE fecha LIKE '" & fechacompro & "%'" & _
  34.                                                 "ORDER BY nombreApellidos", conn)
  35.         Dim reader2 As SqlDataReader
  36.  
  37.         Try
  38.  
  39.             Using conn
  40.  
  41.                 'conn.Open()
  42.                 'With comm1
  43.                 '    reader1 = .ExecuteReader()
  44.                 '    While reader1.Read()
  45.                 '        cuanto = reader1.GetValue(0)
  46.                 '    End While
  47.                 '    .Dispose()
  48.                 'End With
  49.                 'If conn.State = ConnectionState.Open Then
  50.  
  51.                 '    conn.Close()
  52.                 'End If
  53.  
  54.                 conn.Open()
  55.                 With comm2
  56.                     reader2 = .ExecuteReader()
  57.                     While reader2.Read()
  58.                         'For i = 0 To cuanto - 1
  59.                         Dim objRow As New TableRow()
  60.  
  61.                         email = reader2.GetValue(0)
  62.                         nombre = reader2.GetValue(1)
  63.  
  64.                         'For j = 0 To numcells - 1
  65.                         Dim objCell1 As New TableCell()
  66.                         Dim objCell2 As New TableCell()
  67.  
  68.                         objCell1.Controls.Add(New LiteralControl(nombre))
  69.                         objCell2.Controls.Add(New LiteralControl(email))
  70.                         objRow.Cells.Add(objCell1)
  71.                         objRow.Cells.Add(objCell2)
  72.                         'Next
  73.                         Table1.Rows.Add(objRow)
  74.                         'Next
  75.                     End While
  76.                     .Dispose()
  77.                 End With
  78.             End Using
  79.         Catch ex As Exception
  80.  
  81.             MsgBox("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  82.             'mensaje("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  83.         Finally
  84.             conn.Close()
  85.             conn.Dispose()
  86.         End Try
  87.     End Sub

Gracias a todos por vuestra ayuda.

__________________
Gracias por todo;

Un saludo