Hello Guys, My problem is

When i'm trying to run this program Sql QUERY doesn't work properly , but the month and day are okay but it comes to year it doesn't work... :(

anybody can help me please? thanks

Dim strSql As String = "SELECT * FROM tblAudit WHERE Date_Time BETWEEN '" & Format(dtpFROM_F.Value, "MM/dd/yyyy") & "' AND '" & Format(dtpTO_F.Value, "MM/dd/yyyy") & "'"
            classLibrary = New ConLib
            classLibrary.openConnection(strConnection)
            lblconstat.Text = DatabaseStatus
            If Not classLibrary.isconnectionopen() Then
                Exit Sub

            End If

            classLibrary.initializeCommand(strSql)

Recommended Answers

All 3 Replies

All ready lots of post is there similar to your please check This if it solve your problem then ok otherwise feel free to as ask

I have problem using the two Datepicker that search startdate and enddate... like "FROM" "TO" , but only the year doesn't work...

for example i pick (FROM)1/20/2010 - (TO)12/20/2010

Change your string this

Dim strSql As String = "SELECT * FROM tblAudit WHERE Date_Time BETWEEN '" & Format(dtpFROM_F.Value, "MM/dd/yyyy") & "' AND '" & Format(dtpTO_F.Value, "MM/dd/yyyy") & "'"

to

Dim strSql As String = "SELECT * FROM tblAudit WHERE Date_Time BETWEEN '#" & Format(dtpFROM_F.Value, "MM/dd/yyyy") & "#' AND '#" & Format(dtpTO_F.Value, "MM/dd/yyyy") & "#'"

I think you did't follow the link provided in my previous post or you did't read care fully.
If you get any problem then ask your question ..........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.