sql - Column 'book_name' does not belong to table -


i trying add data 2 fields in vb form sql server these column values book_name & member_id through 2 textboxes , search button using following code:

dim b_name string = txtsearchbooknamenew.text dim m_id decimal = txtsearchidnew.text da = new sqldataadapter("select b.book_name, m.member_id book b join member m on b.staff_id = m.staff_id member_id =" & m_id & "and book_name =" & "'" & b_name & "'", cn)                 dt = new datatable                 da.fill(dt)                 if dt.rows.count > 0                     cboidsave.text = dt.rows(0).item("member_id")                     cboisbnsave.text = dt.rows(0).item("book_name")                     end if 

but receiving error: "column 'book_name' not belong table"

what causing error?

after lots of headaches found out filling fields in wrong order, selected "book_name" first in sql query when filling fields(comboboxes ->cboidsave & cboisbnsave) filling first id field book_name field although must fill book_name field first , id field. that's did , code works fine :)

to summarize change this:

 cboidsave.text = dt.rows(0).item("member_id")   cboisbnsave.text = dt.rows(0).item("book_name") 

to this:

cboisbnsave.text = dt.rows(0).item("book_name") cboidsave.text = dt.rows(0).item("member_id") 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -