programadorvb6 Posted February 10, 2012 at 12:15 PM Report #438622 Posted February 10, 2012 at 12:15 PM 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é.
Caça Posted February 10, 2012 at 12:26 PM Report #438623 Posted February 10, 2012 at 12:26 PM Para evitar esse tipo de erros usa parâmetros, ou então passa a data como yyyy-mm-dd. Pedro Martins Não respondo a duvidas por PM
HIT_Braga Posted February 10, 2012 at 12:46 PM Report #438626 Posted February 10, 2012 at 12:46 PM Boas. Eu custumo fazer um FORMAT e colocar a data do tipo yyyy-mm-dd, ou então vê o uso do Cdate. Sds, " Elogios não me elevam, ofensas não me rebaixam, sou o que sou e não o que acham! "
programadorvb6 Posted February 10, 2012 at 02:05 PM Author Report #438652 Posted February 10, 2012 at 02:05 PM 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é.
Caça Posted February 10, 2012 at 02:07 PM Report #438654 Posted February 10, 2012 at 02:07 PM https://wiki.portugal-a-programar.pt/dev_net/vb.net/access/ Pedro Martins Não respondo a duvidas por PM
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