sql server - extract information from MS SQL database -


my database has table called "serialkey" 3 columns id pk email & serial.

i have windows form in vb.net, form has 1 label, 1 textbox, 1 button, text in label displays email address, email address vary. when click button on form want database searched email address , find serial in database. have shown code below gives me error saying "object reference not set instance of object" highlights line below.

dim reader sqldatareader = command.executereader()

can me out here because i'm stuck , new :) appreciated.

con = new sqlconnection("data source= connection string here; password='my password here'; ")     cmd.connection = con         cmd.commandtext = "select serial serialkey serial= ?"         cmd.parameters.addwithvalue("?", lblname.text)         con.open()         dim lrd sqldatareader = cmd.executereader()         while lrd.read()             'do             if lrd.hasrows                 lrd.read()                 userskey.text = lrd.getstring(1)                                textbox2.text = lrd.getstring(2)             end if         end while     catch ex exception         messagebox.show("error while retrieving records on table..." & ex.message, "load records")             con.close()     end try 


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -