sql - Display data from database to textbox -
i trying show data database textbox , write in textbox. last code got. here data showing in datagrid. instead of datagrid how data textboxes.
public sub selectitem(byval itemcode string) try sql.opendbconnection() dim strsql string = "select itemcode 'item code',itemname 'item name' " & _ " tblitemmaster itemcode= @itemcode" dim cmd new sqlcommand(strsql, sql.sqlconn) dim ds new dataset cmd.parameters.addwithvalue("itemcode", itemcode) dim da new sqldataadapter(cmd) da.fill(ds, "tblitemmaster") dgvpurchaseorder.datasource = ds.tables("tblitemmaster") sql.sqlconn.close() catch ex sqlexception msgbox(ex.message, msgboxstyle.critical, "sql error") catch ex exception msgbox(ex.message, msgboxstyle.critical, "general error") end try end sub
i have no idea how that. please me
if want populate textboxes try like...
public sub selectitem(byval itemcode string) try sql.opendbconnection() dim strsql string = "select itemcode [item code],itemname [item name] tblitemmaster itemcode= @itemcode" dim cmd new sqlcommand(strsql, sql.sqlconn) cmd.parameters.addwithvalue("itemcode", itemcode) dim myreader sqldatareader myreader = cmd.executereader() if myreader.hasrows myreader.read() txtitemcode.text = myreader.getvalue(0).tostring() txtitemname.text = myreader.getvalue(1).tostring() else messagebox.show("no data found", "no data") end if myreader.close() sql.sqlconn.close() catch ex sqlexception msgbox(ex.message, msgboxstyle.critical, "sql error") catch ex exception msgbox(ex.message, msgboxstyle.critical, "general error") end try end sub
Comments
Post a Comment