visual studio 2015 - How to select from a cell in mysql and add to button.text -
i'm newbie visual basic 2015 in visual studio community.
what i'm trying on load of main form
i have 7 buttons need text field changed correspond entries in database. these buttons can change categories end user down road. i'm using mysql database. appreciated have searched google , youtube , it's endless world of overload.
my db structure follows since cant embed image: idbtncat btn_name btn_caption panelno btn_image 1 btn_cat1 pizza pnl_cat1 pizza.jpg
public class frm_mainconsole dim conn new mysqlconnection sub dbconn() dim databasename string = "posdb" dim server string = "localhost" dim username string = "root" dim password string = "8943117" if not conn nothing conn.close() conn.connectionstring = string.format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, username, password, databasename) try conn.open() catch ex exception msgbox(ex.message) end try end sub private sub frm_mainconsole_load(sender object, e eventargs) handles mybase.load me.show() dbconn() dim query string dim command mysqlcommand dim reader mysqldatareader try dbconn() query = "select * posdb.button_cat btn_caption" command = new mysqlcommand(query, conn) reader = command.executereader while reader.read btn_cat1.text = reader("btn_caption") conn.close() end while catch ex mysqlexception messagebox.show(ex.message) conn.dispose() end try end sub private sub testdatabaseconnectiontoolstripmenuitem_click(sender object, e eventargs) handles testdatabaseconnectiontoolstripmenuitem.click if mnit_dbconn.text = "db not connected" dbconn() mnit_dbconn.text = "db connected" else mnit_dbconn.text = "db not connected" conn.close() end if end sub
Comments
Post a Comment