sql - Long query won't work -
im new vb , im working on monitoring system long query
if frm_monitoringreg.txtidnumber.text = string.empty or frm_monitoringreg.txtaddress.text = string.empty or frm_monitoringreg.txtbirthplace.text = string.empty or frm_monitoringreg.txtfirstname.text = string.empty or frm_monitoringreg.txtidnumber.text = string.empty or frm_monitoringreg.txtlastname.text = string.empty or frm_monitoringreg.txtmiddlename.text = string.empty or frm_monitoringreg.cmbcivilstatus.selectedindex = 0 or frm_monitoringreg.cmbgender.selectedindex = 0 msgbox("must fill fields") else dim accountds, personds new dataset 'dim command new sqlcommand(sqlcon) 'command.open() dim cmdselectpersoninfo new sqlcommand("select * [186].[dbo].personinfo pidnumber = @pidnumber", connection) cmdselectpersoninfo.commandtype = commandtype.text cmdselectpersoninfo.parameters.addwithvalue("@pidnumber", frm_monitoringreg.txtidnumber.text) dim dadapterperson new sqldataadapter(cmdselectpersoninfo) dadapterperson.fill(personds) if personds.tables(0).rows.count >= 1 msgbox("person information created") else dim cmdaddpersoninfo new sqlcommand("insert [186].[dbo].[personinfo] (pidnumber, plname, pfname, pmname, paddress, " & _ "pgender, pbirthday, pbirthplace, pcivilstatus, deletedflag, createby, createdate,pworking " & _ "poccupation,pstudying,ptschool ,pheducation,pdisability,pyr,pprecinct,pyrbahay,pkpaninirahan " & _ "pkpkanino,pkpupa,pltinitirhan,pltukuyin,pkbahay,pktukuyin,pmbahay,pmtukuyin,pmeralco,pmaynilad " & _ "ptelepono,pbkita,pgpamilya,pkapitbahay,ppalikuran,ppagluluto,pptukuyin,ptubig,pttukuyin,pilaw " & _ "pitukuyin,pltelevision,plvideoke,plsports,plmusical,plreading,plmalling,plhiking,phaso " & _ "phpusa,phmanok,phbaboy,phiba,phbilang,pskotse,psvan,psjeepney,pstricycle,psiba,psiba,pkradio,pkaudio,pkkaraoke " & _ "pkpiano,pkcellphone,pktv,pkvideop,pkcam,pkwood,pkkerosene,pklpg,pkgas,pkestove,pkerange,pkmicrowave " & _ "pkref,pkfreezer,pkwashing,pkheated,pkaircon,pkefan,pketank,pkeheater,pkcomputer,pklaptop,pksystem,pkflati) " & _ "values (@idnumber, @lname, @fname, @mname, @address, @gender, @bday, @bplace, @civilstat, @deletedflag, @createby, @createdate " & _ "@pworking,@poccupation,@pstudying,@ptschool,@pheducation,@pdisability,@pyr,@pprecinct,@pyrbahay,@pkpaninirahan " & _ "@pkpkanino,@pkpupa,@pltinitirhan,@pltukuyin,@pkbahay,@pktukuyin,@pmbahay,@pmtukuyin,@pmeralco,@pmaynilad " & _ "@ptelepono,@pbkita,@pgpamilya,@pkapitbahay,@ppalikuran,@ppagluluto,@pptukuyin,@ptubig,@pttukuyin,@pilaw " & _ "@pitukuyin,@pltelevision,@plvideoke,@plsports,@plmusical,@plreading,@plmalling,@plhiking,@phaso " & _ "@phpusa,@phmanok,@phbaboy,@phiba,@phbilang,@pskotse,@psvan,@psjeepney,@pstricycle,@psiba,@psiba,@pkradio,@pkaudio,@pkkaraoke " & _ "@pkpiano,@pkcellphone,@pktv,@pkvideop,@pkcam,@pkwood,@pkkerosene,@pklpg,@pkgas,@pkestove,@pkerange,@pkmicrowave " & _ "@pkref,@pkfreezer,@pkwashing,@pkheated,@pkaircon,@pkefan,@pketank,@pkeheater,@pkcomputer,@pklaptop,@pksystem,@pkflati)", connection) cmdaddpersoninfo.commandtype = commandtype.text cmdaddpersoninfo.parameters.addwithvalue("@idnumber", frm_monitoringreg.txtidnumber.text) cmdaddpersoninfo.parameters.addwithvalue("@lname", frm_monitoringreg.txtlastname.text) cmdaddpersoninfo.parameters.addwithvalue("@fname", frm_monitoringreg.txtfirstname.text) cmdaddpersoninfo.parameters.addwithvalue("@mname", frm_monitoringreg.txtmiddlename.text) cmdaddpersoninfo.parameters.addwithvalue("@address", frm_monitoringreg.txtaddress.text) cmdaddpersoninfo.parameters.addwithvalue("@gender", frm_monitoringreg.cmbgender.text) cmdaddpersoninfo.parameters.addwithvalue("@bday", frm_monitoringreg.dtpbirthday.text) cmdaddpersoninfo.parameters.addwithvalue("@bplace", frm_monitoringreg.txtbirthplace.text) cmdaddpersoninfo.parameters.addwithvalue("@civilstat", frm_monitoringreg.cmbcivilstatus.text) cmdaddpersoninfo.parameters.addwithvalue("@deletedflag", 0) cmdaddpersoninfo.parameters.addwithvalue("@createby", loginform.txtusername.text) cmdaddpersoninfo.parameters.addwithvalue("@createdate", now.date.tostring) cmdaddpersoninfo.parameters.addwithvalue("@pworking", frm_monitoringreg.chckworking.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@poccupation", frm_monitoringreg.txtoccupation) cmdaddpersoninfo.parameters.addwithvalue("@pstudying", frm_monitoringreg.chckstudying.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@ptschool", frm_monitoringreg.cmbotypeofschool.text) cmdaddpersoninfo.parameters.addwithvalue("@pheducation", frm_monitoringreg.cmbohighesteduc.text) cmdaddpersoninfo.parameters.addwithvalue("@pdisability", frm_monitoringreg.chckdisablity.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@pyr", frm_monitoringreg.txtyrofstay) cmdaddpersoninfo.parameters.addwithvalue("@pprecinct", frm_monitoringreg.txtprecintno) cmdaddpersoninfo.parameters.addwithvalue("@pyrbahay", frm_monitoringreg.txttyr) cmdaddpersoninfo.parameters.addwithvalue("@pkpaninirahan", frm_monitoringreg.cmbokatayuan.text) cmdaddpersoninfo.parameters.addwithvalue("@pkpkanino", frm_monitoringreg.txtkanino) cmdaddpersoninfo.parameters.addwithvalue("@pkpupa", frm_monitoringreg.txtupa) cmdaddpersoninfo.parameters.addwithvalue("@pltinitirhan", frm_monitoringreg.cmbolote.text) cmdaddpersoninfo.parameters.addwithvalue("@pltukuyin", frm_monitoringreg.txtltukuyin) cmdaddpersoninfo.parameters.addwithvalue("@pkbahay", frm_monitoringreg.cmbobahay.text) cmdaddpersoninfo.parameters.addwithvalue("@pktukuyin", frm_monitoringreg.txtbtukuyin) cmdaddpersoninfo.parameters.addwithvalue("@pmbahay", frm_monitoringreg.cmbombahay.text) cmdaddpersoninfo.parameters.addwithvalue("@pmtukuyin", frm_monitoringreg.txtmtukuyin) cmdaddpersoninfo.parameters.addwithvalue("@pmeralco", frm_monitoringreg.chckmeralco.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@pmaynilad", frm_monitoringreg.chckmaynilad.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@ptelepono", frm_monitoringreg.chcktelepono.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@pbkita", frm_monitoringreg.txtkita) cmdaddpersoninfo.parameters.addwithvalue("@pgpamilya", frm_monitoringreg.txtgastos) cmdaddpersoninfo.parameters.addwithvalue("@pkapitbahay", frm_monitoringreg.txtkapitbahay) cmdaddpersoninfo.parameters.addwithvalue("@ppalikuran", frm_monitoringreg.cmbopalikuran.text) cmdaddpersoninfo.parameters.addwithvalue("@ppagluluto", frm_monitoringreg.cmbopagluluto.text) cmdaddpersoninfo.parameters.addwithvalue("@pptukuyin", frm_monitoringreg.txtptukuyin) cmdaddpersoninfo.parameters.addwithvalue("@ptubig", frm_monitoringreg.cmbotubig.text) cmdaddpersoninfo.parameters.addwithvalue("@pttukuyin", frm_monitoringreg.txtttukuyin.text) cmdaddpersoninfo.parameters.addwithvalue("@pilaw", frm_monitoringreg.cmboilaw.text) cmdaddpersoninfo.parameters.addwithvalue("@pitukuyin", frm_monitoringreg.txtitukuyin.text) cmdaddpersoninfo.parameters.addwithvalue("@pltelevision", chcktelevision.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plvideoke", chckvideoke.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plsports", chcksports.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plmusical", chckmusicalinstruments.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plreading", chckreading.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plmalling", chckmalling.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plhiking", chckhiking.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@plreading", chckreading.checkstate) cmdaddpersoninfo.parameters.addwithvalue("@phaso", txtaso.text) cmdaddpersoninfo.parameters.addwithvalue("@phpusa", txtpusa.text) cmdaddpersoninfo.parameters.addwithvalue("@phmanok", txtmanok.text) cmdaddpersoninfo.parameters.addwithvalue("@phbaboy", txtbaboy.text) cmdaddpersoninfo.parameters.addwithvalue("@phiba", txthiba.text) cmdaddpersoninfo.parameters.addwithvalue("@phbilang", txthbilang.text) cmdaddpersoninfo.parameters.addwithvalue("@pskotse", txtkotse.text) cmdaddpersoninfo.parameters.addwithvalue("@psvan", txtvan.text) cmdaddpersoninfo.parameters.addwithvalue("@psjeepney", txtjeepney.text) cmdaddpersoninfo.parameters.addwithvalue("@pstricycle", txttricycle.text) cmdaddpersoninfo.parameters.addwithvalue("@psiba", txtsiba.text) cmdaddpersoninfo.parameters.addwithvalue("@psbilang", txtsbilang.text) cmdaddpersoninfo.parameters.addwithvalue("@pkradio", txtradio.text) cmdaddpersoninfo.parameters.addwithvalue("@pkaudio", txtsystem.text) cmdaddpersoninfo.parameters.addwithvalue("@pkkaraoke", txtkaraoke.text) cmdaddpersoninfo.parameters.addwithvalue("@pkpiano", txtkeyboard.text) cmdaddpersoninfo.parameters.addwithvalue("@pkcellphone", txtcp.text) cmdaddpersoninfo.parameters.addwithvalue("@pktv", txttv.text) cmdaddpersoninfo.parameters.addwithvalue("@pkvideop", txtvideop.text) cmdaddpersoninfo.parameters.addwithvalue("@pkcam", txtcamcorder.text) cmdaddpersoninfo.parameters.addwithvalue("@pkwood", txtwood.text) cmdaddpersoninfo.parameters.addwithvalue("@pkkerosene", txtkerosene.text) cmdaddpersoninfo.parameters.addwithvalue("@pklpg", txtstove.text) cmdaddpersoninfo.parameters.addwithvalue("@pkgas", txtgas.text) cmdaddpersoninfo.parameters.addwithvalue("@pkestove", txtelectric.text) cmdaddpersoninfo.parameters.addwithvalue("@pkerange", txtelectriccooking.text) cmdaddpersoninfo.parameters.addwithvalue("@pkmicrowave", txtoven.text) cmdaddpersoninfo.parameters.addwithvalue("@pkref", txtref.text) cmdaddpersoninfo.parameters.addwithvalue("@pkfreezer", txtfreezer.text) cmdaddpersoninfo.parameters.addwithvalue("@pkwashing", txtwashing.text) cmdaddpersoninfo.parameters.addwithvalue("@pkheated", txtdryer.text) cmdaddpersoninfo.parameters.addwithvalue("@pkaircon", txtaircon.text) cmdaddpersoninfo.parameters.addwithvalue("@pkefan", txtfan.text) cmdaddpersoninfo.parameters.addwithvalue("@pketank", txttank.text) cmdaddpersoninfo.parameters.addwithvalue("@pkeheater", txtheater.text) cmdaddpersoninfo.parameters.addwithvalue("@pkcompute", txtcomputer.text) cmdaddpersoninfo.parameters.addwithvalue("@pklaptop", txtlaptop.text) cmdaddpersoninfo.parameters.addwithvalue("@pksystem", txtgamesystem.text) cmdaddpersoninfo.parameters.addwithvalue("@pkflati", txtflatiron.text) dim dadapter new sqldataadapter(cmdaddpersoninfo) dadapter.fill(accountds) msgbox("information successfuly added") frm_monitoringreg.close() me.close() monitoring.show() end if end if
but when try save error in line
dim dadapter new sqldataadapter(cmdaddpersoninfo) dadapter.fill(accountds)
the error says "no mapping exists object type system.windows.forms.textbox known managed provider native type.". first time tried input program input until table "createby" try find why stops there failed find , error pops out of nowhere. don't know anymore.
you should think doing few things differently.
but anyway: problem because missing .text
number of these statements. need add these lines:
cmdaddpersoninfo.parameters.addwithvalue("@pyr", frm_monitoringreg.txtyrofstay) cmdaddpersoninfo.parameters.addwithvalue("@pprecinct", frm_monitoringreg.txtprecintno) cmdaddpersoninfo.parameters.addwithvalue("@pyrbahay", frm_monitoringreg.txttyr) cmdaddpersoninfo.parameters.addwithvalue("@pkpaninirahan", frm_monitoringreg.cmbokatayuan.text) cmdaddpersoninfo.parameters.addwithvalue("@pkpkanino", frm_monitoringreg.txtkanino) cmdaddpersoninfo.parameters.addwithvalue("@pkpupa", frm_monitoringreg.txtupa) cmdaddpersoninfo.parameters.addwithvalue("@pmtukuyin", frm_monitoringreg.txtmtukuyin) cmdaddpersoninfo.parameters.addwithvalue("@pbkita", frm_monitoringreg.txtkita) cmdaddpersoninfo.parameters.addwithvalue("@pgpamilya", frm_monitoringreg.txtgastos) cmdaddpersoninfo.parameters.addwithvalue("@pkapitbahay", frm_monitoringreg.txtkapitbahay) cmdaddpersoninfo.parameters.addwithvalue("@pptukuyin", frm_monitoringreg.txtptukuyin)
and possibly more have missed.
Comments
Post a Comment