Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi,


I want to fetch the data in my grid view by the difference of two dates and with a name. these all are on the labels
Posted
Comments
MAU787 18-Jul-12 2:20am    
please elaborate more..
not able to understand "with a name" means which name??
Karthik Harve 18-Jul-12 2:21am    
So, what is the problem you are facing? Have you tried anything?
Pradeep_kaushik 18-Jul-12 4:00am    
name is user name or client name
Pradeep_kaushik 18-Jul-12 4:03am    
when i give this code

SqlDataAdapter da = new SqlDataAdapter("select SNO,DATE,PNAME,QUANT,RATE,TOTAL from BILL1 where CNAME='"+Label1.Text+"' and DATE between Convert(datetime, '"+ Label3.Text +"',110) and Convert(datetime, '"+ Label4.Text +"',110)",con);

error message displayed :-
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

when i use the code
SqlDataAdapter da=new SqlDataAdapter("select SNO,DATE,PNAME,QUANT,RATE,TOTAL from BILL1 where CNAME='"+Label1.Text+"' and DATE between '" + dt1.ToShortDateString() + "' and '" + dt2.ToShortDateString() + "'",con);

it does not compare year if i give two dates of 2012 n any entry with 2013 year also displayed

1 solution

You need to try first. Follow these steps:
1. Design a page where you place few search parameters. For example, searching a name in DB, so a textbox for it, from-to date via datepicker or textbox.
2. Now, place a search button as the trigger event of the search. On click of search button you would be writing your logic.
3. In search button click, get the search parameters (like the name in textbox here), use it, form a query and execute on database
4. Get the query result back in a datatable and bind it to a grid or any other appropriate control based on your needs
5. For now, Datagrid will display the retrieved result.

Done! Try!
 
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