vb.net - Populating multiple textboxes with data at once -


i have form containing 6 groupboxes, each groupbox containing 180 textboxes, along 2 combobxes. on selecting value first combobox, second combobox gets filled required data table. requirement upon selecting value second combobox, filtered data same table should fill remaining textboxes. code using follows:

    private sub combobox2_selectedindexchanged(byval sender system.object, byval e system.eventargs) handles combobox2.selectedindexchanged     dim strconnection string = "provider=microsoft.jet.oledb.4.0; data source=c:\\users\\brisingr\\documents\\123\database.mdb"     dim objconnection new oledbconnection(strconnection)      dim strsql string     'strsql = "select * '" & combobox1.text & "' style = '" & combobox2.text & " '"     dim string     dim b string     dim c string     dim d string     = "select * ["     b = combobox1.text     c = "] style = ["     d = combobox2.text     strsql = & b & c & d & "]"     dim objcommand new oledbcommand(strsql, objconnection)      dim objdataadapter new oledbdataadapter(objcommand)     dim objdatatable new datatable("buyers")     objdataadapter.fill(objdatatable)      objconnection.close()     objconnection.dispose()     objconnection = nothing     objcommand.dispose()     objcommand = nothing     objdataadapter.dispose()     objdataadapter = nothing      integer = 1 60         me.controls("l1ob" & i).text = objdatatable.rows(0)("operation" & i)     next  end sub 

here "operation" & (i) refers field name of database, have been named operation1, operation2 , on...

this code not seem working me. please help..

here have many problems

dim string dim b string dim c string dim d string = "select * [" b = combobox1.text c = "] style = [" d = combobox2.text strsql = & b & c & d & "]" dim objcommand new oledbcommand(strsql, objconnection) 

first, have square brackets around value passed field style.
, not valid syntax. jet engine assumes parameter. actually, passing parameter, right way go.

a = "select * ["  b = combobox1.text c = "] style = ?" strsql = & b & c dim objcommand new oledbcommand(strsql, objconnection) objcommand.parameters.addwithvalue("@p1", combobox2.text) dim objdataadapter new oledbdataadapter(objcommand) dim objdatatable new datatable("buyers") objdataadapter.fill(objdatatable) 

the value field style passed parameter. leaves work replace placeholder (?) value taken combobox framework.
sure knows better of avoiding errors , sql injections.

this code still weak. should absolutely sure contents of first combobox1 not modified contains malicious text instead of table names


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -