vb.net - An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dl -


on line line dim read oledb.oledbdatareader = cmd.executereader()it says:

an unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dl.

please can have done correct, not understand why register system not work.

'enables use of oledb classes. imports system imports system.data.oledb  imports system.net.mail  public class register     'determines connection , location within users file system.     dim myconnstring string = "provider=microsoft.jet.oledb.4.0;data source=" & environment.currentdirectory & "\bloodbank.mdb"        private sub register_load(sender object, e eventargs) handles mybase.load         'this line of code loads data 'bloodbankdataset.user' table. can move, or remove it, needed.         me.usertableadapter.fill(me.bloodbankdataset1.user)         'bindingsource - encloses data source form, in case register.         ' addnew, adds new record.         me.userbindingsource.addnew()     end sub      private sub reg_click(sender object, e eventargs) handles reg.click         'creates connection between project , database ensuring changes made updated within database.         dim con new oledbconnection(myconnstring)         'creates second connection between project , database ensuring changes made updated within database.         dim con2 new oledbconnection(myconnstring)         'opens connections.         con.open()         con2.open()         'creates sql command which...         'selects staff details dependendent on value inputted user.         dim cmd oledbcommand = new oledbcommand("select staffid, firstname, surname [staff] (firstname = '" & me.firstnametextbox.text & "') , (surname = '" & me.surnametextbox.text & "') ", con)         'sends command above connection.         dim read oledb.oledbdatareader = cmd.executereader()         'creates sql command which...         'selects user id , staff id user dependent on value inputted user.         dim cmd2 oledbcommand = new oledbcommand("select userid, staffid [user] staffid = '" & me.staffidtextbox.text & "' ", con2)         'sends command above connection.         dim read2 oledb.oledbdatareader = cmd2.executereader()          'if there no text within staff id text box...         if string.isnullorempty(staffidtextbox.text)             'a message appear telling user enter staff id.             msgbox("please enter staffid")             'this focus user on staff id text box.             'me. means current form in use.             me.staffidtextbox.focus()              'if there no text within firstname text box...         elseif string.isnullorempty(firstnametextbox.text)             'a message appear telling user enter first name.             msgbox("please enter first name")             'this focus user on firstname text box.             me.firstnametextbox.focus()              'if there no text within surname text box...         elseif string.isnullorempty(surnametextbox.text)             'a message appear telling user enter surname.             msgbox("please enter surname")             'this focus user on surname text box.             me.surnametextbox.focus()              'if there no text within login id text box...         elseif string.isnullorempty(userlogintextbox.text)             'a message appear telling user enter login id.             msgbox("please enter loginid")             'this focus user on loginid text box.             me.userlogintextbox.focus()              'if there no text within user password text box...         elseif string.isnullorempty(userpasswordtextbox.text)             'a message appear telling user enter password.             msgbox("please enter password")             'this focus user on password text box.             me.userpasswordtextbox.focus()               'if there no text within user id text box...         elseif string.isnullorempty(emailaddresstextbox.text)             'a message appear telling user enter email.             msgbox("please enter email")             'this focus user on email text box.             me.emailaddresstextbox.focus()               'if items not match within database then...         elseif read.read = false             'a message box appear informing of failure of registration , reason why.             msgbox("you must staff member create user")             'this focus user on staffid text box.             me.staffidtextbox.focus()              'if items match within database then...         elseif read2.read = true             'determines answer data type integer.             dim answer integer             'creates message box, assigned answer question yes , no option              answer = msgbox("there user account staff id." & vbnewline & "have forgotten password? ", vbyesno + vbquestion)             'if user selects yes button...             if answer = vbyes                 'they redirected retrieve password form.                 '.show, opens said form, in case retrieve password form.                 retrievepass.show()                 '.close, closes form, in case form in use.                 me.close()             else                 'do nothing.             end if          elseif read2.read = false , me.staffidtextbox.text = read.item("staffid") , me.firstnametextbox.text = read.item("firstname") , me.surnametextbox.text = read.item("surname")          end if          msgbox("thank creating user." & vbnewline & "we have sent user details email")         'security level         'makes feild in specified table usable or not usable user.         homef.butform.enabled = true         homef.butuse.enabled = false         homef.button2.enabled = true          'me. means current form in use.         '.validate checks information correct , every aspect has been filled in.         me.validate()         'endedit, applies changes data source.         me.userbindingsource.endedit()         'updates specified table within specified dataset.         me.usertableadapter.update(me.bloodbankdataset1)          me.userlogin_l.text = me.userlogintextbox.text          '.validate checks information correct , every aspect has been filled in.         me.validate()         'endedit, applies changes data source.           try             dim email string = me.emailaddresstextbox.text             dim name string = me.firstnametextbox.text             dim userpassword string = me.userpasswordtextbox.text             dim loginid string = me.userlogintextbox.text             dim staffid integer = me.staffidtextbox.text              dim smtp_server new smtpclient("smtp.gmail.com")             dim e_mail new mailmessage             smtp_server.usedefaultcredentials = false               'have put in email account details enable use of sending emails via account.             smtp_server.credentials = new net.networkcredential("blood4all1@gmail.com", "blood1234")             smtp_server.port = 587             smtp_server.enablessl = true             'smtp(simple mail transfer protocol)              e_mail.from = new mailaddress("blood4all@outlook.com")             e_mail.to.add(email)             e_mail.subject = ("new user: blood4all blood bank")             e_mail.isbodyhtml = false             e_mail.priority = mailpriority.high             e_mail.body = ("dear " & name & "" & vbnewline & "" & vbnewline & "a new user account created staffid: " & staffid & ". if account not created contact blood4all immediately." & vbnewline & "your loginid is: " & loginid & "" & vbnewline & "your password is: " & userpassword & "" & vbnewline & "" & vbnewline & "regards" & vbnewline & "blood4all blood bank")              smtp_server.send(e_mail)             close()             homef.show()           catch error_t exception             msgbox("error when sending email: email address not exist or there no network connection")             close()             homef.show()          end try          end         'closes 4 objects.         read.close()         read2.close()         con.close()         con2.close()     end sub 


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -