mysql - How to reload list view? -


i have run problem. when main form load, call loadsentnbox()

public sub loadsentbox()     logmysql()     try          dim sqlquery string         logmysql()         sqlquery = "select * files_tr `from` = '" + user + "'"         mysqlcommand = new mysqlcommand(sqlquery, mysqlcon)         'open db         mysqlcon.open()         mysqlreader = mysqlcommand.executereader         while mysqlreader.read             dim listviewitem             ltv_sentbox.beginupdate()             = ltv_sentbox.items.add(mysqlreader.item("to"))             i.subitems.add(mysqlreader.item("filename"))             i.subitems.add(mysqlreader.item("size"))             i.subitems.add(mysqlreader.item("status"))             ltv_inbox.update()             ltv_inbox.endupdate()         end while         mysqlcon.close()         'ltv_sentbox.refresh()     catch ex exception         msgbox(ex.tostring, msgboxstyle.critical)     end try end sub 

it works !. want update database form , close window , update listview on original page. write loadsentbox() in close event, listview shows nothing. solution ? (i'm new vb.net. dont write complex code)

try code
public sub databasetolistview(byval strcon string, byval strcmd string, byval list listview)
list.items.clear()
dim dr1 sqlclient.sqldatareader
dim con new sqlclient.sqlconnection(strcon)
dim integer = 0
dim cmd new sqlclient.sqlcommand
dim item new listviewitem
con.open()
cmd = new sqlclient.sqlcommand(strcmd, con)
dr1 = cmd.executereader
while (dr1.read())
item = new listviewitem()
item.text = dr1(0).tostring
= 1
while < dr1.fieldcount
item.subitems.add(dr1(i).tostring)
= + 1
end while
list.items.add(item)
end while
dr1.close()
con.close()
end sub


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -