Chamuanza Posted September 13, 2014 Report Share Posted September 13, 2014 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 More sharing options...
nelsonr Posted September 14, 2014 Report Share Posted September 14, 2014 O campo data é mesmo do tipo texto na base de dados? Link to comment Share on other sites More sharing options...
Chamuanza Posted September 14, 2014 Author Report Share Posted September 14, 2014 Oi Nelsonr Sim o campo data é do tipo texto. Penso que resolvi a situação com a colocação de TRIM nos campos de Texto do select. Obrigado pela atenção Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now