oledb - Updating Image on database MSAccess Database Vb.net? -


i want update images in database when press button won't update , don't have errors on code. added code in "com.executequery" block try if errors, , messagebox result "error"

 private sub updatebtn_click(byval sender system.object, byval e system.eventargs) handles updatebtn.click             if agetxt.selecteditem = nothing or gendertxt.selecteditem = nothing or yrlvltxt.selecteditem = nothing or picturebox1.image nothing                  msgbox("please not leave required fields blanks.", vbexclamation, "warning!")             else                 dim memstream new memorystream                 dim datapic_update byte()                 me.picturebox1.image.save(memstream, imaging.imageformat.jpeg)                 datapic_update = memstream.getbuffer()                 memstream.read(datapic_update, 0, memstream.length)  'to check if connection open                 if con.state = connectionstate.open                     con.close()                 end if                  'updating db                 dim editq string = "update infos set firstname=@f1, surname=@f2, middlename=@f3, [birthdate]=@f4, gender=@f5, homeaddress=@f6, cityaddress=@f7, baranggayaddress=@f8, emailadd1=@f9, birthplace=@f10, yearlevel=@f11, course=@f12, emailadd2=@f13, [age]=@f14, [telnum]=@f15, [mobilenum1]=@f16, [mobilenum2]=@f17, fathersname=@f18, fathersl=@f19, mothersname=@f20, mothersl=@f21, fathersocc=@f22, mothersocc=@f23, streetadd=@f24, [image]=@image [studentid]=@fid "                 dim com new oledbcommand(editq, con)                 con.open()                   com.parameters.addwithvalue("@fid", stdntid.text.tostring)                 com.parameters.addwithvalue("@f1", fname.text)                 com.parameters.addwithvalue("@f2", sname.text)                 com.parameters.addwithvalue("@f3", mname.text)                 com.parameters.addwithvalue("@f4", datetxt.value.toshortdatestring)                 com.parameters.addwithvalue("@f5", gendertxt.selecteditem.tostring)                 com.parameters.addwithvalue("@f6", homaddtxt.text)                 com.parameters.addwithvalue("@f7", cityadd.text)                 com.parameters.addwithvalue("@f8", brgyadd.text)                 com.parameters.addwithvalue("@f9", emailaddtxt.text)                 com.parameters.addwithvalue("@f10", birthptxt.text)                 com.parameters.addwithvalue("@f11", yrlvltxt.selecteditem.tostring)                 com.parameters.addwithvalue("@f12", coursetxt.text)                 com.parameters.addwithvalue("@f13", emailadd2txt.text)                 com.parameters.addwithvalue("@f14", agetxt.selecteditem.tostring)                 com.parameters.addwithvalue("@f15", telnumtxt.text)                 com.parameters.addwithvalue("@f16", mobilenum1txt.text)                 com.parameters.addwithvalue("@f17", mobilenum2txt.text)                 com.parameters.addwithvalue("@f18", fathersl.text)                 com.parameters.addwithvalue("@f19", fatherstxt.text)                 com.parameters.addwithvalue("@f20", mothersl.text)                 com.parameters.addwithvalue("@f21", motherstxt.text)                 com.parameters.addwithvalue("@f22", focc.text)                 com.parameters.addwithvalue("@f23", mocc.text)                 com.parameters.addwithvalue("@f24", streetadd.text)                   ' image content                 dim image oledbparameter = new oledbparameter("@image", sqldbtype.image)                 image.value = datapic_update                 com.parameters.add(image)                   com.executenonquery()                 if com.executenonquery > 0                     msgbox("records updated.", vbinformation, "updated.")                 else                     msgbox("error")                 end if                end if             con.close()            end sub 

the fact executenonquery call succeeds returns 0 means there no records in database match where clause. reason you're adding parameters incorrectly.

both jet , ace ole db providers use positional parameters only. though can give parameters names, names ignored provider. means need add parameters oledbcommand in same order appear in sql code. not.

in sql code, @fid last parameter last parameter add command:

com.parameters.addwithvalue("@f24", streetadd.text) 

that therefore value being used find matching records. rearrange code adds parameters command , add @fid last , you'll go.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -