vb.net - combobox error:'Cannot bind to the new value member. Parameter name: value' -


i have 3 combobox bind diffrent table. , got such error in title. bellow codes:

mycommand = new sqlcommand("select (firstname +' '+ lastname) fullname tblvisitor", myconnection)    myadapter = new sqldataadapter(mycommand)    myadapter.fill(mydataset, "tblvisitor")    cbovisitor.datasource = mydataset.tables(0)    cbovisitor.displaymember = "fullname"    cbovisitor.valuemember = "visitorid"     'my combobox    mycommand = new sqlcommand("select bookcode tblbook", myconnection)    myadapter = new sqldataadapter(mycommand)    myadapter.fill(mydataset, "tblbook")    cbobookcode.datasource = mydataset.tables(1)    cbobookcode.displaymember = "bookcode"    cbobookcode.valuemember = "bookcode"  'where bookcode pk-column of tblbook     'my combobox    mycommand = new sqlcommand("select (firstname +' '+ lastname) stafffullname tblstaff", myconnection)    myadapter = new sqldataadapter(mycommand)    myadapter.fill(mydataset, "tblstaff")    cbostaff.datasource = mydataset.tables(2)    cbostaff.displaymember = "stafffullname"    cbostaff.valuemember = "staffid" 

through code, got first comboboxthat display query result, other 2 not, , display message 'cannot bind new value member. parameter name: value'. please help...

try this:

mycommand = new sqlcommand("select (firstname +' '+ lastname) fullname tblvisitor;select bookcode tblbook;select (firstname +' '+ lastname) stafffullname tblstaff", myconnection)    myadapter = new sqldataadapter(mycommand)    myadapter.fill(mydataset)     cbovisitor.datasource = mydataset.tables(0)    cbovisitor.displaymember = "fullname"    cbovisitor.valuemember = "visitorid"     'my combobox    cbobookcode.datasource = mydataset.tables(1)    cbobookcode.displaymember = "bookcode"    cbobookcode.valuemember = "bookcode"  'where bookcode pk-column of tblbook     'my combobox    cbostaff.datasource = mydataset.tables(2)    cbostaff.displaymember = "stafffullname"    cbostaff.valuemember = "staffid" 

you confusing things calling .fill() multiple times same dataset. perform better making 1 round-trip database.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -