mysql - How to filter data from SQLDataSource -


i'm trying filter data sqldatasource postcode_data textbox name postcode1.

i using .rowfilter property, it's not working. result, postcode_data still not filtered.

what have desired result?

protected sub button1_click(sender object, e eventargs) handles button1.click     dim dv dataview     dim recpostdes string     dim recmiles integer     dv = ctype(postcode_data.select(datasourceselectarguments.empty), dataview)     dv.rowfilter = "postcode = '" & postcode1.text & "%'"     recpostdes = ctype(dv.table.rows(0)(3), string)     recmiles = ctype(dv.table.rows(0)(5), integer)     if recmiles > 0         des1.text = recpostdes         mile1.text = recmiles     end if end sub 

first, looks you're trying create like expression. if so, change = like

dv.rowfilter = "postcode '" & postcode1.text & "%'" 

dataview
"represents databindable, customized view of datatable sorting, filtering, searching, editing, , navigation. dataview not store data, instead represents connected view of corresponding datatable. changes dataview’s data affect datatable. changes datatable’s data affect dataviews associated it." - msdn -

now, here's problem: you're accessing underlying table (dv.table) , not view.

recpostdes = ctype(dv.item(0).row.item(3), string) recmiles = ctype(dv.item(0).row.item(5), integer) 

or

recpostdes = ctype(dv(0)(3), string) recmiles = ctype(dv(0)(5), integer) 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -