vb.net - Failure to Execute UPDATE Query in ASP.net using VB -
i have been searching in several forums including 1 trouble facing.
currently developing website using visual studio 2017 , database runs ms access 2007. problem facing perhaps not error, because not show error messages, although have put try , catch on codes.
so trying execute update query table have in access fails update. purpose update table called 'datadirikaryawan'.
prior updating, select data per 'nip' (id primary key) , display on web form calling function 'isi' on page_load. users able edit data based on preexisting data.
protected sub page_load(byval sender object, byval e system.eventargs) handles me.load session("editval") = "wamb17001" isi() end sub protected sub isi() dim dr oledb.oledbdatareader dim nip string = session("editval") try using command new oledb.oledbcommand("select * datadirikaryawan nip='" & nip & "'", mdl_koneksi.connection) dr = command.executereader dr.read() lblnip.text = dr.getvalue(0) txtnamadepan.text = dr.getvalue(1) txtnamabelakang.text = dr.getvalue(2) txtnoktp.text = dr.getvalue(3) txtnonpwp.text = dr.getvalue(4) txtalamatktp.text = dr.getvalue(5) txtkabktp.text = dr.getvalue(6) txtprovinsiktp.text = dr.getvalue(7) txtkodeposktp.text = dr.getvalue(8) txtnegaraktp.text = dr.getvalue(9) txtalamattgl.text = dr.getvalue(10) txtkabtgl.text = dr.getvalue(11) txtprovtgl.text = dr.getvalue(12) txtkodepostgl.text = dr.getvalue(13) txtnegaratgl.text = dr.getvalue(14) txtkontak1.text = dr.getvalue(15) txtkontak2.text = dr.getvalue(16) txtkontakdarurat.text = dr.getvalue(17) txthbgn.text = dr.getvalue(18) if dr.getvalue(19) = "laki-laki" rblaki.checked = true else rbperempuan.checked = false end if txtnikah.text = dr.getvalue(20) txtjmlhanak.text = dr.getvalue(21) txttmptlahir.text = dr.getvalue(22) txttgllahir.text = dr.getvalue(23) txtpendidikan.text = dr.getvalue(24) txtnorek.text = dr.getvalue(25) command.dispose() connection.close() dr.close() end using catch end try
upon editing of data in web form update query executed.
private sub simpan() dim nip string = session("editval") try using command new oledb.oledbcommand("update datadirikaryawan set nama_depan=@nama_depan, nama_akhir=@nama_akhir, ktp_no=@ktp_no, no_npwp=@no_npwp, alamat_ktp=@alamat_ktp, kota_ktp=@kota_ktp, provinsi_ktp=@provinsi_ktp, kodepos_ktp=@kodepos_ktp, negara_ktp=@negara_ktp, alamat_tgl=@alamat_ktp, kota_tgl=@kota_tgl, provinsi_tgl=@provinsi_tgl, kodepos_tgl=@kodepos_tgl, negara_tgl=@negara_tgl, cp1=@cp1, cp2=@cp2, kontak_darurat=@kontak_darurat, hbgn_kontak=@hbgn_kontak, jenis_kelamin=@jenis_kelamin, status_nikah=@status_nikah, jmlh_anak=@jmlh_anak, tempat_lahir=@tempat_lahir, tgl_lahir=@tgl_lahir, pendidikan_terakhir=@pendidikan_terakhir, rek_niaga=@rek_niaga nip='" & nip & "'", mdl_koneksi.connection) command.parameters.add(new oledb.oledbparameter("@nama_depan", oledbtype.char)).value = txtnamadepan.text command.parameters.add(new oledb.oledbparameter("@nama_akhir", oledbtype.char)).value = txtnamabelakang.text command.parameters.add(new oledb.oledbparameter("@ktp_no", oledbtype.char)).value = txtnoktp.text command.parameters.add(new oledb.oledbparameter("@no_npwp", oledbtype.char)).value = txtnonpwp.text command.parameters.add(new oledb.oledbparameter("@no_npwp", oledbtype.char)).value = txtnonpwp.text command.parameters.add(new oledb.oledbparameter("@alamat_ktp", oledbtype.char)).value = txtalamatktp.text command.parameters.add(new oledb.oledbparameter("@kota_ktp", oledbtype.char)).value = txtkabktp.text command.parameters.add(new oledb.oledbparameter("@kota_ktp", oledbtype.char)).value = txtkabktp.text command.parameters.add(new oledb.oledbparameter("@provinsi_ktp", oledbtype.char)).value = txtprovinsiktp.text command.parameters.add(new oledb.oledbparameter("@kodepos_ktp", oledbtype.char)).value = txtkodeposktp.text command.parameters.add(new oledb.oledbparameter("@negara_ktp", oledbtype.char)).value = txtnegaraktp.text command.parameters.add(new oledb.oledbparameter("@alamat_tgl", oledbtype.char)).value = txtalamattgl.text command.parameters.add(new oledb.oledbparameter("@kota_tgl", oledbtype.char)).value = txtkabtgl.text command.parameters.add(new oledb.oledbparameter("@provinsi_tgl", oledbtype.char)).value = txtprovtgl.text command.parameters.add(new oledb.oledbparameter("@kodepos_tgl", oledbtype.char)).value = txtkodepostgl.text command.parameters.add(new oledb.oledbparameter("@negara_tgl", oledbtype.char)).value = txtnegaratgl.text command.parameters.add(new oledb.oledbparameter("@cp1", oledbtype.char)).value = txtkontak1.text command.parameters.add(new oledb.oledbparameter("@cp2", oledbtype.char)).value = txtkontak2.text command.parameters.add(new oledb.oledbparameter("@kontak_darurat", oledbtype.char)).value = txtkontakdarurat.text command.parameters.add(new oledb.oledbparameter("@hbgn_kontak", oledbtype.char)).value = txthbgn.text if rblaki.checked = true command.parameters.add(new oledb.oledbparameter("@jenis_kelamin", oledbtype.char)).value = rblaki.text else command.parameters.add(new oledb.oledbparameter("@jenis_kelamin", oledbtype.char)).value = rbperempuan.text end if command.parameters.add(new oledb.oledbparameter("@status_nikah", oledbtype.char)).value = txtnikah.text command.parameters.add(new oledb.oledbparameter("@jmlh_anak", oledbtype.char)).value = txtjmlhanak.text command.parameters.add(new oledb.oledbparameter("@tempat_lahir", oledbtype.char)).value = txttmptlahir.text command.parameters.add(new oledb.oledbparameter("@tgl_lahir", oledbtype.char)).value = txttgllahir.text command.parameters.add(new oledb.oledbparameter("@pendidikan_terakhir", oledbtype.char)).value = txtpendidikan.text command.parameters.add(new oledb.oledbparameter("@rek_niaga", oledbtype.char)).value = txtnorek.text command.parameters.add(new oledb.oledbparameter("@nip", oledbtype.char)).value = lblnip.text command.executenonquery() command.dispose() connection.close() session("editval") = "" page.response.redirect("frmredirectinsertdata.aspx") end using catch ex exception lblpesan.visible = true msgbox(ex.message) end try end sub
then function 'simpan', containing update query called in btnsimpan.click.
protected sub btnsimpan_click(sender object, e eventargs) handles btnsimpan.click simpan() session("editval") = "" end sub
now here anomalies:
despite having try catch, not shown error messages. web form refreshed same data previous , table in ms access not updated.
if did not call function 'isi' on page_load fill web form preexisting data, update query works find.
i have used same methods , codes in other forms different tables , worked fine.
i have been spending couple of days now, trying compare tables in access , codes in visual studio , have found no difference of codes , settings/properties.
thus, may need kind assistance solve problems. cheers!
Comments
Post a Comment