sql server - In Visual Studio 2013 I simply want to pass data to a sql table using VB? -
i designing application forte have code end. using visual studio 2013 devexpress , sql server 2014. may simple question have struggled find straight answer anywhere. have asp.net book still cant find answer. think have connected whole solution connection string in can populate tables , stored procedures dataclass. want add user input table on sql server using button onclick event. surely cant difficult remember bit of newbie appreciated. if there questions need answered assist let me know. writing in vb script struggling work. advice appreciated. in advance!
protected sub btnaddnewsource_click(sender system.object, e eventargs) handles btnaddnewsource.click 'errdetails.text = "" 'errdetails.visible = false 'focusset = false 'errcount = 0 'errdetails.text = "" 'if txtsourcefunding.text = "" ' errdetails.text = errdetails.text + "did enter funding source?" + vbnewline ' errdetails.visible = true ' txtsourcefunding.focus() ' focusset = true ' errcount = errcount + 1 'end if 'if txtcontributionfunding.text = "" ' errdetails.text = errdetails.text + "did enter contribution?" + vbnewline ' errdetails.visible = true ' txtcontributionfunding.focus() ' focusset = true ' errcount = errcount + 1 'end if 'if cmbstatus.value = -1 ' errdetails.text = errdetails.text + "did inform of status?" + vbnewline ' errdetails.visible = true ' cmbstatus.focus() ' focusset = true ' errcount = errcount + 1 'end if 'if focusset = true ' errdetails.forecolor = drawing.color.red ' errdetails.height = 20 * errcount ' errdetails.visible = true ' return 'end if 'dim btnsource = (from o in dc1.update_grantapplicationcyclefunding o.grantapplicationid = session("currentprojectid").tostring).firstordefault 'if not isnothing(btnsource) ' btnsource.grantapplicationid = session("currentprojectid") ' btnsource.grantapplicationcyclefundingsource = txtsourcefunding.tostring ' btnsource.grantapplicationcyclefundingcontribution = txtcontributionfunding.tostring ' btnsource.grantapplicationcyclefundingstatusid = cmbstatus.tostring ' btnsource.grantapplicationcyclefundingnotes = memfundingnotes.tostring 'else ' dim newgrantapplicationcyclefundings new grantapplicationcyclefunding ' newgrantapplicationcyclefundings ' .grantapplicationid = session("currentprojectid") ' .grantapplicationcyclefundingsource = txtsourcefunding.tostring ' .grantapplicationcyclefundingcontribution = txtcontributionfunding.tostring ' .grantapplicationcyclefundingstatusid = cmbstatus.tostring ' .grantapplicationcyclefundingnotes = memfundingnotes.text ' end ' dc1.grantapplicationcyclefundings.insertonsubmit(newgrantapplicationcyclefundings) ' dc1.submitchanges() ' end if 'dc1.submitchanges()
hey have managed make button add data datagrid. big thing missed declarations of fields values @ bottom of code , of course databind! never forget correct databind. can adapt , use in own code if having similar problems! if need or explanation , can will. add comment. thanks
** errdetails.text = "" errdetails.visible = false focusset = false errcount = 0 errdetails.text = "" if spntotalestimatedcost.value <= 0 errdetails.text = errdetails.text + "please enter cost." + vbnewline errdetails.visible = true if focusset = false spntotalestimatedcost.focus() focusset = true end if errcount = errcount + 1 end if if txtsourcefunding.text = "" errdetails.text = errdetails.text + "please........?" + vbnewline errdetails.visible = true txtsourcefunding.focus() focusset = true errcount = errcount + 1 end if if spncontributionfunding.value = 0 errdetails.text = errdetails.text + "please......" + vbnewline errdetails.visible = true spncontributionfunding.focus() focusset = true errcount = errcount + 1 end if if focusset = true errdetails.forecolor = drawing.color.red errdetails.height = 20 * errcount errdetails.visible = true return end if dim newgrantapplicationmatchfundings new grantapplicationmatchfunding newgrantapplicationmatchfundings .grantapplicationid = session("currentprojectid") .grantapplicationmatchfundingname = txtsourcefunding.text .grantapplicationmatchfundingcontribution = spncontributionfunding.value .grantapplicationmatchfundingstatus = cmbstatus.selecteditem.value .grantapplicationmatchfundingnotes = memfundingnotes.text end dc1.grantapplicationmatchfundings.insertonsubmit(newgrantapplicationmatchfundings) dc1.submitchanges() 'end if 'dc1.submitchanges() txtsourcefunding.text = "" spncontributionfunding.value = "" cmbstatus.value = "" memfundingnotes.text = "" grdfunding.databind() dim btntotal = (from o in dc1.select_grantapplicationmatchfundingtotal(session("currentprojectid").tostring)).firstordefault if not isnothing(btntotal) spntotalmatchfunding.text = btntotal.totalfunding txtgrantfunding.text = (spntotalmatchfunding.value / spntotalestimatedcost.value) * 100 else spntotalmatchfunding.text = 0 txtgrantfunding.text = 0 end if dim cafchange = (from o in dc1.grantapplicationcostsandfundings o.grantapplicationid.tostring = session("currentprojectid").tostring).firstordefault if not isnothing(cafchange) cafchange.grantapplicationid = session("currentprojectid") cafchange.grantapplicationprojectcostsyear1 = spntotalestimatedcost.value cafchange.grantapplicationmatchedfundingnotesyear1 = memnotesmatchfunding.text cafchange.grantapplicationprojectrequestedyear1 = txtgrantfunding.value dc1.submitchanges() else dim newgrantapplicationcostsandfundings new grantapplicationcostsandfunding newgrantapplicationcostsandfundings .grantapplicationid = session("currentprojectid") .grantapplicationprojectcostsyear1 = spntotalestimatedcost.value .grantapplicationmatchedfundingnotesyear1 = memnotesmatchfunding.text .grantapplicationprojectrequestedyear1 = txtgrantfunding.value end dc1.grantapplicationcostsandfundings.insertonsubmit(newgrantapplicationcostsandfundings) dc1.submitchanges() end if
end sub
Comments
Post a Comment