.net - How to display the current month records from Access database in a datagridview on form load in vb.net -


i can display records code below see current month records, or @ least last 31 days

public sub display_data()   con.open() 'opening connection   dim dt new datatable("tblmph")  dim rs new oledb.oledbdataadapter("select * tblmph", con)  rs.fill(dt)  datagridview1.datasource = dt  datagridview1.refresh()   label1.text = dt.rows.count   rs.dispose()   con.close()   end sub  

first, change field data type date. dates should handled dates, not strings, no exceptions.

second, can use dataview control filtering described here:

how filter datagridview in vb.net

your filter should >= monthfirst , <= monthlast, , these can found way:

dim today datetime = datetime.today dim monthfirst = new datetime(today.year, today.month, 1) dim monthlast = monthfirst.addmonths(1).adddays(-1) 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -