Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/10/2008, 21:45
dieama
 
Fecha de Ingreso: octubre-2008
Ubicación: Córdoba
Mensajes: 31
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Como obtener el rango entre 2 DateTimePicker?

Escribi tal cual me dijiste:


Public Class FrmListado

Private Sub cmdGenerar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerar.Click
Dim cnn As New OleDbConnection
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim cmd As New OleDbCommand
'abro la conexion
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\base.mdb"
cnn.Open()
'creo el comando y lleno la tabla
cmd.Connection = cnn
cmd.CommandText = "Select * From Compras " & _
" Where Fecha between '" & dtpInicio.Value.ToString("MM/dd/yyyy") & _
"' And '" & dtpFinal.Value.ToString("MM/dd/yyyy") & "' Order By Fecha"
cmd.CommandType = CommandType.TableDirect
da.SelectCommand = cmd
da.Fill(dt)
cnn.Close()
dgvListado.DataSource = dt
End Sub

y me salio este error sobre da.Fill(dt)

No coinciden los tipos de datos en la expresión de criterios.