TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Violeta Popa
NA
137
164.4k
filter listview
Mar 24 2013 6:10 PM
hi :)
i want to display in a listview only the insurances that have the expiration day between two dates, here's my code...please tell me what's wrong :(
DateTime date1 = dateTimePicker1.Value;
DateTime date2 = dateTimePicker2.Value;
listView1.Items.Clear();
SqlCommand cmd = new SqlCommand("SELECT * FROM client JOIN obtine ON client.id_client=obtine.id_client JOIN polita ON obtine.cod_polita=polita.cod_polita", conn);
SqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
string[] array = dataReader["perioada_asigurare"].ToString().Split('-');
DateTime dt1 = DateTime.Parse(array[1]);
//int result1=DateTime.Compare(date1,dt1); i tried this too
//int result2 = DateTime.Compare(date2, dt1);
if (dt1>=date1 && dt1 <= date2)
{
ListViewItem item = new ListViewItem(dataReader["denumire"].ToString());
item.SubItems.Add(dataReader["societate"].ToString());
item.SubItems.Add(dataReader["tip_polita"].ToString());
item.SubItems.Add(dataReader["serie"].ToString());
listView1.Items.Add(item);
}
}
Reply
Answers (
2
)
How to pass a Guid parameter to Stored Proc
How to create excel file on another computer