Ya he solucionado el tema. Pongo aquí el código por si a alguien le hace falta:
Código vb.net:
Ver originalProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim fechaActual As Date
Dim nombre, email, mesAnterior, fechacompro, anoActual As String
Dim mesActual As Integer
'Dim i, j, cuanto As Integer
'Dim numcells As Integer = 2
'i = 0
fechaActual = Now.Date
mesActual
= Month(fechaActual
) anoActual
= Year(fechaActual
)
If mesActual = 1 Then
mesAnterior = 12
Else
mesAnterior = mesActual - 2
'mesAnterior = mesActual
End If
If mesAnterior < 10 Then
mesAnterior = "0" + mesAnterior
End If
fechacompro = anoActual + "-" + mesAnterior + "-"
Dim conn As New SqlConnection(WebConfigurationManager.ConnectionStrings("conexionDesa").ConnectionString)
'Dim comm1 As SqlCommand = New SqlCommand("SELECT COUNT(DISTINCT(email)) " & _
' "FROM dbo.temp_datosComunesConceptos " & _
' "WHERE fecha LIKE '" & fechacompro & "%'", conn)
'Dim reader1 As SqlDataReader
Dim comm2 As SqlCommand = New SqlCommand("SELECT DISTINCT(email), nombreApellidos " & _
"FROM dbo.temp_datosComunesConceptos " & _
"WHERE fecha LIKE '" & fechacompro & "%'" & _
"ORDER BY nombreApellidos", conn)
Dim reader2 As SqlDataReader
Try
Using conn
'conn.Open()
'With comm1
' reader1 = .ExecuteReader()
' While reader1.Read()
' cuanto = reader1.GetValue(0)
' End While
' .Dispose()
'End With
'If conn.State = ConnectionState.Open Then
' conn.Close()
'End If
conn.Open()
With comm2
reader2 = .ExecuteReader()
While reader2.Read()
'For i = 0 To cuanto - 1
Dim objRow As New TableRow()
email = reader2.GetValue(0)
nombre = reader2.GetValue(1)
'For j = 0 To numcells - 1
Dim objCell1 As New TableCell()
Dim objCell2 As New TableCell()
objCell1.Controls.Add(New LiteralControl(nombre))
objCell2.Controls.Add(New LiteralControl(email))
objRow.Cells.Add(objCell1)
objRow.Cells.Add(objCell2)
'Next
Table1.Rows.Add(objRow)
'Next
End While
.Dispose()
End With
End Using
Catch ex As Exception
'mensaje("Error en BD" & Chr(13) & Chr(13) & ex.Message)
Finally
conn.Dispose()
End Try
End Sub
Gracias a todos por vuestra ayuda.
