vb.net - How to Show my My Queried Data using OleDbDataReader vb -


i know walk in park of on site, n00b me giving me little trouble now, i'm trying program "query" button show/search data access file based on string entered in corresponding textbox. example if trying search access db employees named eric. want able type eric in firstname txtbox , show list of employees named eric within access file. far have code runs without error when click button whatever in textbox disappears. positive im missing , need guidance. here code far.doing in vb please help!!!

using con = new oledbconnection("provider=microsoft.ace.oledb.12.0;data source=c:\users\eric\documents\fadv.accdb")         dim sql string = ("select firstname, lastname info")          dim cmd new oledbcommand(sql, con)         con.open()          dim reader oledbdatareader         reader = cmd.executereader()          while reader.read()             txtfirstname.text = reader(0).tostring()              console.writeline(" {0} = {1}", reader("firstname"),                  reader("lastname"))              txtfirstname.text = reader(0).tostring()          end while         reader.close()  end using 

using con = new oledbconnection("provider= blah blah blah...")     dim sql string = "select firstname, lastname info firstname = ?"      ' oledbcommand supports dispose     using cmd new oledbcommand(sql, con)         cmd.parameters.addwithvalue("@p1", txtwhere.text)          con.open()          dim reader oledbdatareader         reader = cmd.executereader()          ' listbox store more 1 result         lstresults.items.clear          ' clear old stuff          while reader.read()             lstresults.items.add(string.format("{0}, {1}",                  reader.item(1).tostring, reader.item(0).tostring())              console.writeline(" {0} = {1}", reader("firstname"),                  reader("lastname"))         end while         reader.close()    end using  end using 

the sql can modified search names like, can find eric, erin , erica @ once. can use other data access methods simple fire query , bind controls datagridview results.

finally, parameters protect visit little bobby tables. learn them, know them, love them.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -