Selecting records between two dates

Hello,

I'me trying to select the records that are on the database with the field 'Data" between two dates that are inserted into two fields: "DeData" and "aData". I've the following code but I'm getting an error on my SQL statment:

Private Sub DeData_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeData.ValueChanged
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=""C:\Programa?ao\Visual Basic\Inapal\ReportIt\ReportIt.mdb"";"
con.Open()
sSQL = "SELECT * FROM [RelatorioQuery] WHERE ((Data >'#" & DeData.Text & "#') AND (Data <'#" & aData.Text & "#')) AND (Descri?ao LIKE'%" & SearchBox.Text & "%')"
da = New OleDb.OleDbDataAdapter(sSQL, con)
ds.Clear()
da.Fill(ds, "RelatorioQuery")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "RelatorioQuery"
con.Close()
End Sub

Can annyone help me please?

Thanks,

Jo?o Pinto

[1142 byte] By [JoaoPinto] at [2007-12-24]
# 1

Without knowing the exact error you're getting I'll have to guess what may be wrong. My best guesses are:

1) Remove the single qoute from your date parameters, in Access it should be contained in just pound signs: ColumnName < #1/1/1980#
2) In Access, the LIKE operator uses an asterisk not a percent: ColumnName LIKE '*this text*'

Richard_Wolf at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks for your help.

In fact, the mistake that I had was the single quotes. Without it, it works fine.

Jo?o Pinto

JoaoPinto at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...