Click here to Skip to main content
15,668,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I work on project c# with SQL server and I changed the database in SQLite I faced a problem with between date filter in the crystal report
I try this code it shows the last item date only and sometimes not showing anything any help

What I have tried:

SQLiteConnection con = new SQLiteConnection("Data Source=HospitalDB.db;datetimeformat=currentCulture;version=3;");

DateTime from = DateTime.Parse(dateTimePicker1.Value.ToString());
DateTime to = DateTime.Parse(dateTimePicker2.Value.ToString());
SQLiteCommand cmd = new SQLiteCommand("select* from BillTbl where PDate>= '" + from + "' and PDate<= '" + to + "'", con);
SQLiteDataAdapter sd = new SQLiteDataAdapter(cmd);
DataSet s = new DataSet();
CrystalReport1 sr = new CrystalReport1();
crystalReportViewer1.ReportSource = sr;
Updated 10-Dec-22 4:12am

1 solution

Pass the dates as a parameterised query: that way the value received by the DB engine will already be a DATE based value and the comparison should work fine: Parameters - Microsoft.Data.Sqlite | Microsoft Learn[^]

That assumes of course that the column you are checking against is DATE based: if it's a string based column then you will need to change your DB design or it will never work well.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900