Jump to content

[Resolvido] Select Incompleto


Chamuanza
 Share

Recommended Posts

Um bem aja a todos

Estou todo baralhado e necessito de ajuda

Ao fazer um select numa aplicação que estou a construir verifco que não reporta todos os registos com as condições do select

A BD em Access tem o campo "Data" defenido como Texto. No entanto verifico que existem registos so com a data "2014-06-25" e outros registos com datahora "2014-06-25 10:27:57"

Tambem verifico que no select aparecem registos dos dois tipos, ( "2014-06-25" - "2014-06-25 10:27:57" ), mas faltam registos que estão na BD

Junto o código que estou a usar

//
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    'Dim DataInicio As New DateTime(DateTimePicker1.Value.Year, DateTimePicker1.Value.Month, DateTimePicker1.Value.Day, 0, 0, 0)
    'Dim DataFim As New DateTime(DateTimePicker2.Value.Year, DateTimePicker2.Value.Month, DateTimePicker2.Value.Day, 0, 0, 0)
    Dim DataInicio As Date = DateTimePicker1.Value
    Dim DataFim As Date = DateTimePicker2.Value

    Dim ConnectionString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Justino\Documents\DespesasCaseiras\DespesasPessoaisFamiliares.mdb;")
    Dim Query As String = "SELECT Id,Data,Designacao,Despesa,Categoria,SubCategoria,Familiar FROM DadosActuais Where Data BETWEEN '" & DataInicio & "' AND '" & DataFim & "'AND Categoria Like '" & TextBox1.Text.ToString & "%' AND SubCategoria Like '" & TextBox2.Text.ToString & "%' AND Familiar Like '" & TextBox3.Text.ToString & "%' Order By Id"

    Dim DataAdapter As New OleDbDataAdapter(Query, ConnectionString)
    Dim MyData As New DataSet
    DataAdapter.Fill(MyData, "DadosActuais")
    ' Neste caso utilizei uma datagridview para visualizar os dados
    Me.DataGridView1.DataSource = MyData.Tables("DadosActuais")
    'Conta as linhas da Grid e coloca na Label
    Label1.Text = Nothing
    Label1.Text = "Este Filtro encontrou - " & Me.DataGridView1.RowCount - 1 & " Registos"
    Button2.Enabled = True
    Call ControlaGrid()
    Call SomarColunas()

   End Sub
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.