Jump to content

Recommended Posts

Posted

Olá boa tarde.

Estou com dificuldade em resolver este erro, talvez me possam ajudar, já vi em vários sites algumas sugestões para resolver filtragem de dados entre duas datas em BD Acess com instruções em SQL, mas até agora não tive êxito.

O que poderá ser?

Junto anexo alguns dados :

- O erro : http://img208.imageshack.us/img208/6632/duvida.png

- No Módulo :

Imports System.Data.OleDb
Module Ligacao_BD

Public Sub Procura_Especifica(ByVal Codigo_Sql As String, F As RegistoH)
       Dim Liga_BD As String = ConString.ToString

       Dim ObjCommandoP As New OleDbCommand
       ObjCommandoP.Connection = New OleDbConnection(Liga_BD)
       ObjCommandoP.CommandText = Codigo_Sql.ToString

       ObjCommandoP.Connection.Open()

       Dim ObjLerDados As OleDbDataReader = ObjCommandoP.ExecuteReader()
       If Codigo_Sql.ToString <> Nothing Then
           Try
               If ObjLerDados.HasRows Then
                   Do While ObjLerDados.Read()
                       F.Caixa_Nome.Text = Convert.ToString(ObjLerDados(1))
                       F.Caixa_Razao.Text = Convert.ToString(ObjLerDados(2))
                       F.Caixa_Piso.Text = Convert.ToString(ObjLerDados(3))
                       F.Caixa_Empresa.Text = Convert.ToString(ObjLerDados(6))

                   Loop
               Else
                   MessageBox.Show("Valores não encontrados. ", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error)
               End If

               ObjLerDados.Close()
               ObjLerDados.Dispose()
           Catch ex As Exception
               MessageBox.Show("Erro descrição : " & vbCrLf & ex.Message & vbCrLf, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error)
           End Try
       End If
   End Sub
End Module

- Para Chamar a rotina :

Call Procura_Especifica("SELECT * FROM FolhaLab WHERE Data Between '" & Me.Data_De.Value.Date & "' And '" & Me.Data_Ate.Value.Date & "'" & "Order By Data", Folha_Laboral.RegistoH)

Grato desde já pela vossa atenção.

Programadorvb6.

EDIT: GeSHi adicionado

______________________________________________________________________________

Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
 

Posted

Já tentei fazer assim, mas sem sucesso .

Call Procura_Especifica("SELECT * FROM FolhaLab WHERE Data Between #" & Format(Me.Data_De.Value, "dd/mm/yyyy") & "# And #" & Format(Me.Data_Ate.Value, "dd/mm/yyyy") & "#", Folha_Laboral.RegistoH)
Call Procura_Especifica("SELECT * FROM FolhaLab WHERE Data Between '" & Me.Data_De.Value.Date & "' And '" & Me.Data_Ate.Value.Date & "'" & " Order By Data", Folha_Laboral.RegistoH)
Call Procura_Especifica("SELECT * FROM FolhaLab WHERE Data Between '" & Format(Me.Data_De.Value.Date, "YYYY-MM-DD") & "' And '" & Format(Me.Data_Ate.Value.Date, "YYYY-MM-DD") & "'" & " Order By Data", Folha_Laboral.RegistoH)
Call Procura_Especifica("SELECT * FROM FolhaLab WHERE Data Between CONVERT(DATE,'" & Format(Me.Data_De.Value.Date, "yyyy-MM-dd") & "',102) And CONVERT(DATE,'" & Format(Me.Data_Ate.Value, "yyyy-MM-dd") & "',102)" & " Order By Data", Folha_Laboral.RegistoH) 

EDIT: GeSHi adicionado

______________________________________________________________________________

Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
 

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
×
×
  • 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.