C#, Datagridview, SQL Server -


i have sql server database table called purchase. in windows form, have 2 datagridview (datagridview1, datagridview2). datagridview1 bound purchase table , shows of purchases including column purchasedatetime.

i have datetimepicker1 on form.

i want show specific date chosen user in datetimepicer1 , filter datagridview1 , show filtered data in datagridview2.

i appreciate if me in case.

use following code:

try {   con.open();    cmd=new sqlcommand("select * purchasetable convert(nvarchar(11),datecol)=convert(datetime,@dtpvalue)",conn);   cmd.parameters.addwithvalue("@dtpvalue",dtpdate.value.date.tostring("dd/mm/yyyy");   sqldataadapter adapter = new sqldataadapter(command);   dataset ds = new dataset();   adapter.fill(dataset);   gv.datasource=ds.tables[0];   con.close(); } catch(exception ex) { } {   con.close(); } 

write code on date change event.

hope helpful.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -