vb.net - How to fill up the AutoCompleteCustomSource -
how fill autocompletecustomsource list query results using data reader in vb.net ?
an example code needed.
edit 1:
this have tried , not working
private sub cbemployeeno_click(byval sender object, byval e system.eventargs) handles cbemployeeno.click cbemployeeno.autocompletecustomsource.clear() dim myselectquery string = "select * employeetable " & cbsearch.text & " '" & cbemployeeno.text & "' , status '" & cbstatus.text & "'" dim myconnstring string = "data source=" & application.startuppath & "\database\simpledb.db3" dim sqconnection new sqliteconnection(myconnstring) dim sqcommand new sqlitecommand(myselectquery, sqconnection) sqconnection.open() try dim sqreader sqlitedatareader = sqcommand.executereader() dim m integer while sqreader.read m = 1 sqreader.fieldcount() - 1 if (not sqreader.isdbnull(m)) if cbsearch.text = "employeeid" cbemployeeno.autocompletecustomsource.add(sqreader.getint32(m)) else cbemployeeno.autocompletecustomsource.add(sqreader.getstring(m)) end if end if next m loop sqreader.close() catch ex exception msgbox("error: " & ex.tostring, vbexclamation) sqconnection.close() end try end sub
edit 2: second code tried (following link in devexpress's answer). not working either
private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim sstringcoll new autocompletestringcollection dim myselectquery string = "select * employeetable " & cbsearch.text & " '" & cbemployeeno.text & "' , status '" & cbstatus.text & "'" dim myconnstring string = "data source=" & application.startuppath & "\database\simpledb.db3" dim sqconnection new sqliteconnection(myconnstring) dim sqcommand new sqlitecommand(myselectquery, sqconnection) sqconnection.open() dim sqreader sqlitedatareader = sqcommand.executereader() while sqreader.read() sstringcoll.addrange(new string() {sqreader(0)}) end while cbemployeeno.autocompletecustomsource = sstringcoll end sub
i have found code looking at:
Comments
Post a Comment