Solved

Error message: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Posted on 2004-10-27
680 Views
Last Modified: 2008-02-01
I have a form written in ASP.NET that adds a record to a SQL table via a stored procedure.  There are 116 fields that get collected and passed back to the stored procedure to be inserted into the table.  I thought I have worked out all the bugs, but when I fill out the form and submit it, I get the strange error "Index (zero based) must be greater than or equal to zero and less than the size of the argument list."  The line errors when I execute the stored procedure.  I am at my wits end and cannot find the problem.  Sorry about all the variables but It was the only way I knew to make it work.  Here's the ASP.NET code:


                 'RegionID = Session("RegionID")
                  RegionID = 1


                 If Not IsPostBack then
                    ClientID = request.querystring("id")
                     BindDataGrid(ClientID)
                 End IF
         End Sub

    Sub Button_Click(s AS Object,  e As DataGridCommandEventArgs)

    dim AppNum as textbox = Ctype(e.item.findcontrol("AppNum"), textbox)
    dim ClientSIN as textbox = Ctype(e.item.findcontrol("ClientSIN"), textbox)
    dim Address as textbox = Ctype(e.item.findcontrol("Address"), textbox)
    dim City as textbox = Ctype(e.item.findcontrol("City"), textbox)
    dim Postal as textbox = Ctype(e.item.findcontrol("Postal"), textbox)
    dim Phone as textbox = Ctype(e.item.findcontrol("Phone"), textbox)
    dim Phone2 as textbox = Ctype(e.item.findcontrol("Phone2"), textbox)
    dim DateCreated as textbox = Ctype(e.item.findcontrol("DateCreated"), textbox)
    dim DateRecv as textbox = Ctype(e.item.findcontrol("DateRecv"), textbox)
    dim FirstApp as radiobuttonlist = Ctype(e.item.findcontrol("FirstApp"), radiobuttonlist)
    dim FirstAppDate as textbox = Ctype(e.item.findcontrol("FirstAppDate"), textbox)
    dim Agency_ID as textbox = Ctype(e.item.findcontrol("Agency_ID"), textbox)
    dim AmountR as textbox = Ctype(e.item.findcontrol("AmountR"), textbox)
    dim AmountF as textbox = Ctype(e.item.findcontrol("AmountF"), textbox)
    dim Approved as Checkbox = Ctype(e.item.findcontrol("Approved"), Checkbox)
    dim ReasonRent as checkbox = Ctype(e.item.findcontrol("ReasonRent"), checkbox)
    dim ReasonUtil as checkbox = Ctype(e.item.findcontrol("ReasonUtil"), checkbox)
    dim ReasonStart as checkbox = Ctype(e.item.findcontrol("ReasonStart"),checkbox)
    dim ChqPayName as textbox = Ctype(e.item.findcontrol("ChqPayName"), textbox)
    dim ChqPayAddress as textbox = Ctype(e.item.findcontrol("ChqPayAddress"), textbox)
    dim ChqPayCity as textbox = Ctype(e.item.findcontrol("ChqPayCity"), textbox)
    dim ChqPayPostal as textbox = Ctype(e.item.findcontrol("ChqPayPostal"), textbox)
    dim ChqPayPhone as textbox = Ctype(e.item.findcontrol("ChqPayPhone"), textbox)
    dim ChqPayFax as textbox = Ctype(e.item.findcontrol("ChqPayFax"), textbox)
    dim Explaination as textbox = Ctype(e.item.findcontrol("Explaination"), textbox)
    dim OtherAsst1 as textbox = Ctype(e.item.findcontrol("OtherAsst1"), textbox)
    dim OtherAsst2 as textbox = Ctype(e.item.findcontrol("OtherAsst2"), textbox)
    dim OtherAsst3 as textbox = Ctype(e.item.findcontrol("OtherAsst3"), textbox)
    dim Maintain as textbox = Ctype(e.item.findcontrol("Maintain"), textbox)
    dim Repayment as textbox = Ctype(e.item.findcontrol("Repayment"), textbox)
    dim NegotiatePay as textbox = Ctype(e.item.findcontrol("NegotiatePay"), textbox)
    dim PlaceEmploy1 as textbox = Ctype(e.item.findcontrol("PlaceEmploy1"), textbox)
    dim Income1 as textbox = Ctype(e.item.findcontrol("Income1"), textbox)
    dim PlaceEmploy2 as textbox = Ctype(e.item.findcontrol("PlaceEmploy2"), textbox)
    dim Income2 as textbox = Ctype(e.item.findcontrol("Income2"), textbox)
    dim IncomeOW as textbox = Ctype(e.item.findcontrol("IncomeOW"), textbox)
    dim IncomeChild as textbox = Ctype(e.item.findcontrol("IncomeChild"), textbox)
    dim IncomeOther as textbox = Ctype(e.item.findcontrol("IncomeOther"), textbox)
    dim IncomeSupport as textbox = Ctype(e.item.findcontrol("IncomeSupport"), textbox)
    dim IncomeOldAge as textbox = Ctype(e.item.findcontrol("IncomeOldAge"), textbox)
    dim TotalMonthIncome as textbox = Ctype(e.item.findcontrol("TotalMonthIncome"), textbox)
    dim ExpRentMort as textbox = Ctype(e.item.findcontrol("ExpRentMort"), textbox)
    dim ExpElec as textbox = Ctype(e.item.findcontrol("ExpElec"), textbox)
    dim ExpHeat as textbox = Ctype(e.item.findcontrol("ExpHeat"), textbox)
    dim ExpWaterSew as textbox = Ctype(e.item.findcontrol("ExpWaterSew"), textbox)
    dim ExpPhone as textbox = Ctype(e.item.findcontrol("ExpPhone"), textbox)
    dim ExpCable as textbox = Ctype(e.item.findcontrol("ExpCable"), textbox)
    dim ExpCar as textbox = Ctype(e.item.findcontrol("ExpCar"), textbox)
    dim ExpLoansCC as textbox = Ctype(e.item.findcontrol("ExpLoansCC"), textbox)
    dim ExpOther as textbox = Ctype(e.item.findcontrol("ExpOther"), textbox)
    dim OweRentMort as textbox = Ctype(e.item.findcontrol("OweRentMort"), textbox)
    dim OweElec as textbox = Ctype(e.item.findcontrol("OweElec"), textbox)
    dim OweHeat as textbox = Ctype(e.item.findcontrol("OweHeat"), textbox)
    dim OweWaterSew as textbox = Ctype(e.item.findcontrol("OweWaterSew"), textbox)
    dim OwePhone as textbox = Ctype(e.item.findcontrol("OwePhone"), textbox)
    dim OweCable as textbox = Ctype(e.item.findcontrol("OweCable"), textbox)
    dim OweCar as textbox = Ctype(e.item.findcontrol("OweCar"), textbox)
    dim OweLoansCC as textbox = Ctype(e.item.findcontrol("OweLoansCC"), textbox)
    dim OweOther as textbox = Ctype(e.item.findcontrol("OweOther"), textbox)
    dim TotalOwing as textbox = Ctype(e.item.findcontrol("TotalOwing"), textbox)
    dim TotalMonthly as textbox = Ctype(e.item.findcontrol("TotalMonthly"), textbox)
    dim TotalIncome as textbox = Ctype(e.item.findcontrol("TotalIncome"), textbox)
    dim TotalExpenses as textbox = Ctype(e.item.findcontrol("TotalExpenses"), textbox)
    dim MonthlyBalance as textbox = Ctype(e.item.findcontrol("MonthlyBalance"), textbox)
    dim PresentAddress as textbox = Ctype(e.item.findcontrol("PresentAddress"), textbox)
    dim PresentCity as textbox = Ctype(e.item.findcontrol("PresentCity"), textbox)
    dim PresentPostal as textbox = Ctype(e.item.findcontrol("PresentPostal"), textbox)
    dim PresentLL as textbox = Ctype(e.item.findcontrol("PresentLL"), textbox)
    dim PresLLAddress as textbox = Ctype(e.item.findcontrol("PresLLAddress"), textbox)
    dim PresLLCity as textbox = Ctype(e.item.findcontrol("PresLLCity"), textbox)
    dim PresLLPostal as textbox = Ctype(e.item.findcontrol("PresLLPostal"), textbox)
    dim PresLLPhone as textbox = Ctype(e.item.findcontrol("PresLLPhone"), textbox)
    dim PresentUtil as textbox = Ctype(e.item.findcontrol("PresentUtil"), textbox)
    dim PresentRent as textbox = Ctype(e.item.findcontrol("PresentRent"), textbox)
    dim PresentTime as textbox = Ctype(e.item.findcontrol("PresentTime"), textbox)
    dim FutureAddress as textbox = Ctype(e.item.findcontrol("FutureAddress"), textbox)
    dim FutureCity as textbox = Ctype(e.item.findcontrol("FutureCity"), textbox)
    dim FuturePostal as textbox = Ctype(e.item.findcontrol("FuturePostal"), textbox)
    dim FutureLL as textbox = Ctype(e.item.findcontrol("FutureLL"), textbox)
    dim FutureLLAddress as textbox = Ctype(e.item.findcontrol("FutureLLAddress"), textbox)
    dim FutureLLCity as textbox = Ctype(e.item.findcontrol("FutureLLCity"), textbox)
    dim FutureLLPostal as textbox = Ctype(e.item.findcontrol("FutureLLPostal"), textbox)
    dim FutureLLPhone as textbox = Ctype(e.item.findcontrol("FutureLLPhone"), textbox)
    dim FutureUtil as textbox = Ctype(e.item.findcontrol("FutureUtil"), textbox)
    dim FutureRent as textbox = Ctype(e.item.findcontrol("FutureRent"), textbox)
    dim PrevAddress as textbox = Ctype(e.item.findcontrol("PrevAddress"), textbox)
    dim PrevCity as textbox = Ctype(e.item.findcontrol("PrevCity"), textbox)
    dim PrevPostal as textbox = Ctype(e.item.findcontrol("PrevPostal"), textbox)
    dim PrevLL as textbox = Ctype(e.item.findcontrol("PrevLL"), textbox)
    dim PrevLLAddress as textbox = Ctype(e.item.findcontrol("PrevLLAddress"), textbox)
    dim PrevLLCity as textbox = Ctype(e.item.findcontrol("PrevLLCity"), textbox)
    dim PrevLLPostal as textbox = Ctype(e.item.findcontrol("PrevLLPostal"), textbox)
    dim PrevLLPhone as textbox = Ctype(e.item.findcontrol("PrevLLPhone"), textbox)
    dim HouseholdName1 as textbox = Ctype(e.item.findcontrol("HouseholdName1"), textbox)
    dim HouseholdAge1 as textbox = Ctype(e.item.findcontrol("HouseholdAge1"), textbox)
    dim HouseholdRelation1 as textbox = Ctype(e.item.findcontrol("HouseholdRelation1"), textbox)
    dim HouseholdName2 as textbox = Ctype(e.item.findcontrol("HouseholdName2"), textbox)
    dim HouseholdAge2 as textbox = Ctype(e.item.findcontrol("HouseholdAge2"), textbox)
    dim HouseholdRelation2 as textbox = Ctype(e.item.findcontrol("HouseholdRelation2"), textbox)
    dim HouseholdName3 as textbox = Ctype(e.item.findcontrol("HouseholdName3"), textbox)
    dim HouseholdAge3 as textbox = Ctype(e.item.findcontrol("HouseholdAge3"), textbox)
    dim HouseholdRelation3 as textbox = Ctype(e.item.findcontrol("HouseholdRelation3"), textbox)
    dim HouseholdName4 as textbox = Ctype(e.item.findcontrol("HouseholdName4"), textbox)
    dim HouseholdAge4 as textbox = Ctype(e.item.findcontrol("HouseholdAge4"), textbox)
    dim HouseholdRelation4 as textbox = Ctype(e.item.findcontrol("HouseholdRelation4"), textbox)
    dim HouseholdName5 as textbox = Ctype(e.item.findcontrol("HouseholdName5"), textbox)
    dim HouseholdAge5 as textbox = Ctype(e.item.findcontrol("HouseholdAge5"), textbox)
    dim HouseholdRelation5 as textbox = Ctype(e.item.findcontrol("HouseholdRelation5"), textbox)
    dim HouseholdName6 as textbox = Ctype(e.item.findcontrol("HouseholdName6"), textbox)
    dim HouseholdAge6 as textbox = Ctype(e.item.findcontrol("HouseholdAge6"), textbox)
    dim HouseholdRelation6 as textbox = Ctype(e.item.findcontrol("HouseholdRelation6"), textbox)
    dim HousingLivable as textbox = Ctype(e.item.findcontrol("HousingLivable"), textbox)
    dim Evicted as textbox = Ctype(e.item.findcontrol("Evicted"), textbox)
    dim RelateLL as textbox = Ctype(e.item.findcontrol("RelateLL"), textbox)
    dim OtherInfo as textbox = Ctype(e.item.findcontrol("OtherInfo"), textbox)
    dim Consent as checkbox = Ctype(e.item.findcontrol("Consent"), checkbox)

           dim strAppNum as Integer
            dim strClientSIN As Integer
            dim strAddress As String
            dim strCity As String
            dim strPostal As String
            dim strPhone As String
            dim strPhone2 As String
            dim strDateCreated as datetime
            dim strDateRecv as datetime
            dim strFirstApp As integer
            dim strFirstAppDate as string
            dim strAgency_ID as String
            dim strAmountR as integer
            dim strAmountF as integer
            dim strApproved as integer
            dim strReasonRent as String
            dim strReasonUtil as String
            dim strReasonStart as String
            dim strChqPayName as String
            dim strChqPayAdress as String
            dim strChqPayCity as String
            dim strChqPayPostal as String
            dim strChqPayPhone as String
            dim strChqPayFax as String
            dim strExplaination as String
            dim strOtherAsst1 as String
            dim strOtherAsst2 as String
            dim strOtherAsst3 as String
            dim strMaintain as String
            dim strRepayment as String
            dim strNegotiatePay as String
            dim strPlaceEmploy1 as String
            dim strIncome1 as integer
            dim strPlaceEmploy2 as String
            dim strIncome2 as integer
            dim strIncomeOW as integer
            dim strIncomeChild as integer
            dim strIncomeOther as integer
            dim strIncomeSupport as integer
            dim strIncomeOldAge as integer
            dim strTotalMonthIncome as integer
            dim strExpRentMort as integer
            dim strExpElect as integer
            dim strExpHeat as integer
            dim strExpWaterSew as integer
            dim strExpPhone as integer
            dim strExpCable as integer
            dim strExpCar as integer
            dim strExpLoansCC as integer
            dim strExpOther as integer
            dim strOweRentMort as integer
            dim strOweElect as integer
            dim strOweHeat as integer
            dim strOweWaterSew as integer
            dim strOwePhone as integer
            dim strOweCable as integer
            dim strOweCar as integer
            dim strOweLoansCC as integer
            dim strOweOther as integer
            dim strTotalOwing as integer
            dim strTotalMonthly as  integer
            dim strTotalIncome as integer
            dim strTotalExpenses as integer
            dim strMonthlyBalance as integer
    dim   strPresentAddress as string
    dim   strPresentCity as string
    dim   strPresentPostal as string
    dim   strPresentLL as string
    dim   strPresLLAddress as string
    dim   strPresLLCity as string
    dim   strPresLLPostal as string
    dim   strPresLLPhone as string
    dim   strPresentUtil as integer
    dim   strPresentRent as integer
    dim   strPresentTime as string
    dim   strFutureAddress as string
    dim   strFutureCity as string
    dim   strFuturePostal as string
    dim   strFutureLL as string
    dim   strFutureLLAddress as string
    dim   strFutureLLCity as string
    dim   strFutureLLPostal as string
    dim   strFutureLLPhone as string
    dim   strFutureUtil as integer
    dim   strFutureRent as integer
    dim   strPrevAddress as string
    dim   strPrevCity as string
    dim   strPrevPostal as string
    dim   strPrevLL as string
    dim   strPrevLLAddress as string
    dim   strPrevLLCity as string
    dim   strPrevLLPostal as string
    dim   strPrevLLPhone as string
    dim   strHouseholdName1 as string
    dim   strHouseholdAge1 as integer
    dim   strHouseholdRelation1 as string
    dim   strHouseholdName2 as string
    dim   strHouseholdAge2 as integer
    dim   strHouseholdRelation2 as string
    dim   strHouseholdName3 as string
    dim   strHouseholdAge3 as integer
    dim   strHouseholdRelation3 as string
    dim   strHouseholdName4 as string
    dim   strHouseholdAge4 as integer
    dim   strHouseholdRelation4 as string
    dim   strHouseholdName5 as string
    dim   strHouseholdAge5 as integer
    dim   strHouseholdRelation5 as string
    dim   strHouseholdName6 as string
    dim   strHouseholdAge6 as integer
    dim   strHouseholdRelation6 as string
    dim   strHousingLivable as string
    dim   strEvicted as string
    dim   strRelateLL as string
    dim   strOtherInfo as string
    dim   strconsent as integer
                  
          strAppNum=AppNum.text
          strClientSIN = ClientSIN.text
          strAddress  = Address.text
          strCity  = City.text
          strPostal  = Postal.text
          strPhone  = Phone.text
            strPhone2  = Phone2.text
            strDateCreated  = DateCreated.text
            strDateRecv     = DateRecv.text
            strFirstApp  = FirstApp.selecteditem.value
            strFirstAppDate  = FirstAppDate.text
            strAgency_ID= Agency_ID.text
            strAmountR  = AmountR.text
            strAmountF  = AmountF.text
            strApproved  = Approved.checked
            strReasonRent  = ReasonRent.checked
            strReasonUtil  = ReasonUtil.checked
            strReasonStart  = ReasonStart.checked
            strChqPayName  = ChqPayName.text
            strChqPayAdress  = ChqPayAddress.text
            strChqPayCity  = ChqPayCity.text
            strChqPayPostal  = ChqPayPostal.text
            strChqPayPhone  = ChqPayPhone.text
            strChqPayFax  = ChqPayFax.text
            strExplaination  = Explaination.text
            strOtherAsst1  = OtherAsst1.text
            strOtherAsst2  = OtherAsst2.text
            strOtherAsst3  = OtherAsst3.text
            strMaintain  = Maintain.text
            strRepayment  = Repayment.text
            strNegotiatePay  = NegotiatePay.text
            strPlaceEmploy1  = PlaceEmploy1.text
            strIncome1  = Income1.text
            strPlaceEmploy2  = PlaceEmploy2.text
            strIncome2  = Income2.text
            strIncomeOW  = IncomeOW.text
            strIncomeChild  = IncomeChild.text
            strIncomeOther  = IncomeOther.text
            strIncomeSupport  = IncomeSupport.text
            strIncomeOldAge  = IncomeOldAge.text
            strTotalMonthIncome = TotalMonthIncome.text
            strExpRentMort  = ExpRentMort.text
            strExpElect  = ExpElec.text
            strExpHeat  = ExpHeat.text
            strExpWaterSew  = ExpWaterSew.text
            strExpPhone  = ExpPhone.text
            strExpCable  = ExpCable.text
            strExpCar  = ExpCar.text
            strExpLoansCC  = ExpLoansCC.text
            strExpOther  = ExpOther.text
            strOweRentMort  = OweRentMort.text
            strOweElect  = OweElec.text
            strOweHeat  = OweHeat.text
            strOweWaterSew  = OweWaterSew.text
            strOwePhone  = OwePhone.text
            strOweCable  = OweCable.text
            strOweCar  = OweCar.text
            strOweLoansCC  = OweLoansCC.text
            strOweOther  = OweOther.text
            strTotalOwing=TotalOwing.text
            strTotalMonthly =TotalMonthly.text
            strTotalIncome =TotalIncome.text
            strTotalExpenses =TotalExpenses.text
            strMonthlyBalance =MonthlyBalance.text
            strPresentAddress =PresentAddress.text
            strPresentCity =PresentCity.text
            strPresentPostal=PresentPostal.text
            strPresentLL =PresentLL.text
            strPresLLAddress=PresLLAddress.text
            strPresLLCity  =PresLLCity.text
            strPresLLPostal=PresLLPostal.text
            strPresLLPhone=PresLLPhone.text
            strPresentUtil=PresentUtil.text
            strPresentRent=PresentRent.text
            strPresentTime=PresentTime.text
            strFutureAddress=FutureAddress.text
            strFutureCity =FutureCity.text
            strFuturePostal=FuturePostal.text
            strFutureLL=FutureLL.text
            strFutureLLAddress=FutureLLAddress.text
            strFutureLLCity =FutureLLCity.text
            strFutureLLPostal=FutureLLPostal.text
            strFutureLLPhone =FutureLLPhone.text
            strFutureUtil=FutureUtil.text
            strFutureRent =FutureRent.text
            strPrevAddress =PrevAddress.text
            strPrevCity=PrevCity.text
            strPrevPostal=PrevPostal.text
            strPrevLL =PrevLL.text
            strPrevLLAddress=PrevLLAddress.text
            strPrevLLCity =PrevLLCity.text
            strPrevLLPostal=PrevLLPostal.text
            strPrevLLPhone =PrevLLPhone.text
            strHouseholdName1=HouseholdName1.text
            strHouseholdAge1 =HouseholdAge1.text
            strHouseholdRelation1 =HouseholdRelation1.text
            strHouseholdName2 =HouseholdName2.text
            strHouseholdAge2 =HouseholdAge2.text
            strHouseholdRelation2 =HouseholdRelation2.text
            strHouseholdName3 =HouseholdName3.text
            strHouseholdAge3 =HouseholdAge3.text
            strHouseholdRelation3 =HouseholdRelation3.text
            strHouseholdName4 =HouseholdName4.text
            strHouseholdAge4 =HouseholdAge4.text
            strHouseholdRelation4 =HouseholdRelation4.text
            strHouseholdName5 =HouseholdName5.text
            strHouseholdAge5 =HouseholdAge5.text
            strHouseholdRelation5 =HouseholdRelation5.text
            strHouseholdName6 =HouseholdName6.text
            strHouseholdAge6 =HouseholdAge6.text
            strHouseholdRelation6 =HouseholdRelation6.text
            strHousingLivable = HousingLivable.text
            strEvicted = Evicted.text
            strRelateLL = RelateLL.text
            strOtherInfo = OtherInfo.text
            strconsent = consent.checked
                  if strreasonrent = "0n" then
                  strreasonrent = 1
                  else
                  strreasonrent = 0
                  end if
                  if strreasonUtil = "0n" then
                  strreasonutil = 1
                  else
                  strreasonutil = 0
                  end if
                  if strreasonStart = "0n" then
                  strreasonstart = 1
                  else
                  strreasonstart = 0
                  end if

            dim cmd As oledbCommand
            cmd = New oledbCommand("sp_FlexFund_new", Connect2)
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add("@ClientAppID", strAppNum)
            cmd.Parameters.Add("@ClientSIN", strClientSIN)
            cmd.Parameters.Add("@Address", strAddress)
            cmd.Parameters.Add("@City", strCity)
            cmd.Parameters.Add("@Postal", strPostal)
            cmd.Parameters.Add("@Phone", strPhone)
            cmd.Parameters.Add("@Phone2", strPhone2)
            cmd.Parameters.Add("@DateCreated", strDateCreated)
            cmd.Parameters.Add("@DateRecv", strDateRecv)
            cmd.Parameters.Add("@FirstApp", strFirstApp)
            cmd.Parameters.Add("@FirstAppDate", strFirstAppDate)
            cmd.Parameters.Add("@Agency_ID",strAgency_ID)
            cmd.Parameters.Add("@AmountR", strAmountR)
            cmd.Parameters.Add("@AmountF", strAmountF)
            cmd.Parameters.Add("@Approved", strApproved)
            cmd.Parameters.Add("@ReasonRent", strReasonRent)
            cmd.Parameters.Add("@ReasonUtil", strReasonUtil)
            cmd.Parameters.Add("@ReasonStart", strReasonStart)
            cmd.Parameters.Add("@ChqPayName", strChqPayName)
            cmd.Parameters.Add("@ChqPayAddress", strChqPayAdress)
            cmd.Parameters.Add("@ChqPayCity", strChqPayCity)
            cmd.Parameters.Add("@ChqPayPostal", strChqPayPostal)
            cmd.Parameters.Add("@ChqPayPhone", strChqPayPhone)
            cmd.Parameters.Add("@ChqPayFax", strChqPayFax)
            cmd.Parameters.Add("@Explaination", strExplaination)
            cmd.Parameters.Add("@OtherAsst1", strOtherAsst1)
            cmd.Parameters.Add("@OtherAsst2", strOtherAsst2)
            cmd.Parameters.Add("@OtherAsst3", strOtherAsst3)
            cmd.Parameters.Add("@Maintain", strMaintain)
            cmd.Parameters.Add("@Repayment", strRepayment)
            cmd.Parameters.Add("@NegotiatePay", strNegotiatePay)
            cmd.Parameters.Add("@PlaceEmploy1", strPlaceEmploy1)
            cmd.Parameters.Add("@Income1", strIncome1)
            cmd.Parameters.Add("@PlaceEmploy2", strPlaceEmploy2)
            cmd.Parameters.Add("@Income2", strIncome2)
            cmd.Parameters.Add("@IncomeOW", strIncomeOW)
            cmd.Parameters.Add("@IncomeChild", strIncomeChild)
            cmd.Parameters.Add("@IncomeOther", strIncomeOther)
            cmd.Parameters.Add("@IncomeSupport", strIncomeSupport)
            cmd.Parameters.Add("@IncomeOldAge", strIncomeOldAge)
            cmd.Parameters.Add("@TotalMonthlyIncome", strTotalMonthIncome)
            cmd.Parameters.Add("@ExpRentMort", strExpRentMort)
            cmd.Parameters.Add("@ExpElec", strExpElect)
            cmd.Parameters.Add("@ExpHeat", strExpHeat)
            cmd.Parameters.Add("@ExpWaterSew", strExpWaterSew)
            cmd.Parameters.Add("@ExpPhone", strExpPhone)
            cmd.Parameters.Add("@ExpCable", strExpCable)
            cmd.Parameters.Add("@ExpCar", strExpCar)
            cmd.Parameters.Add("@ExpLoansCC", strExpLoansCC)
            cmd.Parameters.Add("@ExpOther", strExpOther)
            cmd.Parameters.Add("@OweRentMort", strOweRentMort)
            cmd.Parameters.Add("@OweElec", strOweElect)
            cmd.Parameters.Add("@OweHeat", strOweHeat)
            cmd.Parameters.Add("@OweWaterSew", strOweWaterSew)
            cmd.Parameters.Add("@OwePhone", strOwePhone)
            cmd.Parameters.Add("@OweCable", strOweCable)
            cmd.Parameters.Add("@OweCar", strOweCar)
            cmd.Parameters.Add("@OweLoansCC", strOweLoansCC)
            cmd.Parameters.Add("@OweOther", strOweOther)
            cmd.Parameters.Add("@TotalOwing1",strTotalOwing)
            cmd.Parameters.Add("@TotalMonthly",strTotalMonthly)
            cmd.Parameters.Add("@TotalIncome",strTotalIncome)
            cmd.Parameters.Add("@TotalExpenses",strTotalExpenses)
            cmd.Parameters.Add("@MonthlyBalance",strMonthlyBalance)
            cmd.Parameters.Add("@PresentAddress",strPresentAddress)
            cmd.Parameters.Add("@PresentCity",strPresentCity)
            cmd.Parameters.Add("@PresentPostal",strPresentPostal)
            cmd.Parameters.Add("@PresentLL",strPresentLL)
            cmd.Parameters.Add("@PresLLAddress",strPresLLAddress)
            cmd.Parameters.Add("@PresLLCity",strPresLLCity)
            cmd.Parameters.Add("@PresLLPostal",strPresLLPostal)
            cmd.Parameters.Add("@PresLLPhone",strPresLLPhone)
            cmd.Parameters.Add("@PresentUtil",strPresentUtil)
            cmd.Parameters.Add("@PresentRent",strPresentRent)
            cmd.Parameters.Add("@PresentTime",strPresentTime)
            cmd.Parameters.Add("@FutureAddress",strFutureAddress)
            cmd.Parameters.Add("@FutureCity",strFutureCity)
            cmd.Parameters.Add("@FuturePostal",strFuturePostal)
            cmd.Parameters.Add("@FutureLL",strFutureLL)
            cmd.Parameters.Add("@FutureLLAddress",strFutureLLAddress)
            cmd.Parameters.Add("@FutureLLCity",strFutureLLCity)
            cmd.Parameters.Add("@FutureLLPostal",strFutureLLPostal)
            cmd.Parameters.Add("@FutureLLPhone",strFutureLLPhone)
            cmd.Parameters.Add("@FutureUtil",strFutureUtil)
            cmd.Parameters.Add("@FutureRent",strFutureRent)
            cmd.Parameters.Add("@PrevAddress",strPrevAddress)
            cmd.Parameters.Add("@PrevCity",strPrevCity)
            cmd.Parameters.Add("@PrevPostal",strPrevPostal)
            cmd.Parameters.Add("@PrevLL",strPrevLL)
            cmd.Parameters.Add("@PrevLLAddress",strPrevLLAddress)
            cmd.Parameters.Add("@PrevLLCity",strPrevLLCity)
            cmd.Parameters.Add("@PrevLLPostal",strPrevLLPostal)
            cmd.Parameters.Add("@PrevLLPhone",strPrevLLPhone)
            cmd.Parameters.Add("@HouseholdName1",strHouseholdName1)
            cmd.Parameters.Add("@HouseholdAge1",strHouseholdAge1)
            cmd.Parameters.Add("@HouseholdRelation1",strHouseholdRelation1)
            cmd.Parameters.Add("@HouseholdName2",strHouseholdName2)
            cmd.Parameters.Add("@HouseholdAge2",strHouseholdAge2)
            cmd.Parameters.Add("@HouseholdRelation2",strHouseholdRelation2)
            cmd.Parameters.Add("@HouseholdName3",strHouseholdName3)
            cmd.Parameters.Add("@HouseholdAge3",strHouseholdAge3)
            cmd.Parameters.Add("@HouseholdRelation3",strHouseholdRelation3)
            cmd.Parameters.Add("@HouseholdName4",strHouseholdName4)
            cmd.Parameters.Add("@HouseholdAge4",strHouseholdAge4)
            cmd.Parameters.Add("@HouseholdRelation4",strHouseholdRelation4)
            cmd.Parameters.Add("@HouseholdName5",strHouseholdName5)
            cmd.Parameters.Add("@HouseholdAge5",strHouseholdAge5)
            cmd.Parameters.Add("@HouseholdRelation5",strHouseholdRelation5)
            cmd.Parameters.Add("@HouseholdName6",strHouseholdName6)
            cmd.Parameters.Add("@HouseholdAge6",strHouseholdAge6)
            cmd.Parameters.Add("@HouseholdRelation6",strHouseholdRelation6)
            cmd.Parameters.Add("@HousingLivable", HousingLivable)
            cmd.Parameters.Add("@Evicted", Evicted)
            cmd.Parameters.Add("@RelateLL", RelateLL)
            cmd.Parameters.Add("@OtherInfo", OtherInfo)
            cmd.Parameters.Add("@Consent", Consent)

       
        connect2.open()
        cmd.ExecuteNonQuery()

        connect2.close()
        response.redirect("../_admin/clients/adminclients.aspx")



            End Sub

    Sub BindDataGrid(ClientID AS Integer)

                      dim GetContactCommand AS OleDBcommand= New OleDBCommand("Select * FROM tblclients WHERE tblClients.ApplicationID="& ClientID, Connect2)
                   
                      Dim Adapter AS OleDBDataAdapter = new OleDBDataAdapter
                      Adapter.Selectcommand = getContactCommand
                      Adapter.SelectCommand.Connection.Open

                      dim ContactDS AS DataSet = New DataSet
                      Adapter.Fill(ContactDS, "Contact")

                      ContactGrid.DataSource = ContactDS

                      Page.dataBind()
              End Sub

and the stored procedure:

CREATE procedure dbo.sp_FlexFund_new (

      @ClientAppID int,
      @ClientSIN int,
      @Address varchar (100),
      @City char (20),
      @Postal char (7),
      @Phone char (12),
      @Phone2 char (12),
      @DateCreated datetime,
      @DateRecv datetime,
      @FirstApp bit,
      @FirstAppDate datetime,
      @Agency_ID varchar(50),
      @AmountR int,
      @AmountF int,
      @Approved bit,
      @ReasonRent bit,
      @ReasonUtil bit,
      @ReasonStart bit,
      @ChqPayName char (20),
      @ChqPayAddress varchar (50),
      @ChqPayCity char (20),
      @ChqPayPostal char (6),
      @ChqPayPhone char (18),
      @ChqPayFax char (18),
      @Explaination varchar (50),
      @OtherAsst1 varchar (50),
      @OtherAsst2 varchar (50),
      @OtherAsst3 varchar (50),
      @Maintain varchar (50),
      @Repayment varchar (50),
      @NegotiatePay varchar (50),
      @PlaceEmploy1 text,
      @Income1 int,
      @PlaceEmploy2 text,
      @Income2 int,
      @IncomeOW int,
      @IncomeChild int,
      @IncomeOther int,
      @IncomeSupport int,
      @IncomeOldAge int,
      @TotalMonthlyIncome int,
      @ExpRentMort int,
      @ExpElec int,
      @ExpHeat int,
      @ExpWaterSew int,
      @ExpPhone int,
      @ExpCable int,
      @ExpCar int,
      @ExpLoansCC int,
      @ExpOther int,
      @OweRentMort int,
      @OweElec int,
      @OweHeat int,
      @OweWaterSew int,
      @OwePhone int,
      @OweCable int,
      @OweCar int,
      @OweLoansCC int,
      @OweOther int,
      @TotalOwing   int,
      @TotalMonthly   int,
      @TotalIncome  int,
      @TotalExpenses  int,
      @MonthlyBalance int,
      @PresentAddress varchar (50),  
      @PresentCity varchar (50),
      @PresentPostal varchar (50),  
      @PresentLL varchar (50),
      @PresLLAddress varchar (50),  
      @PresLLCity varchar (50),
      @PresLLPostal varchar (50),  
      @PresLLPhone text,
      @PresentUtil int,
      @PresentRent int,  
      @PresentTime char (10),  
      @FutureAddress varchar (50),  
      @FutureCity char (10),
      @FuturePostal char (10),  
      @FutureLL char (10),
      @FutureLLAddress char (10),  
      @FutureLLCity char (10),
      @FutureLLPostal char (10),        
      @FutureLLPhone char (10),  
      @FutureUtil int,
      @FutureRent int,
      @PrevAddress char (10),  
      @PrevCity char (10),
      @PrevPostal char (10),  
      @PrevLL char (10),
      @PrevLLAddress char (10),
      @PrevLLCity char (10),
      @PrevLLPostal char (10),  
      @PrevLLPhone char (10),
      @HouseholdName1 char (10),  
      @HouseholdAge1 int,
      @HouseholdRelation1 char (10),  
      @HouseholdName2 char (10),
      @HouseholdAge2 int,
      @HouseholdRelation2 char (10),
      @HouseholdName3 char (10),
      @HouseholdAge3 int,
      @HouseholdRelation3 char (10),
      @HouseholdName4 char (10),
      @HouseholdAge4 int,
      @HouseholdRelation4 char (10),
      @HouseholdName5 char (10),
      @HouseholdAge5 int,
      @HouseholdRelation5 char (10),
      @HouseholdName6 char (10),
      @HouseholdAge6 int,
      @HouseholdRelation6 char (10),
      @HousingLivable varchar (50),
      @Evicted varchar (50),
      @RelateLL varchar (50),
      @OtherInfo varchar (50),    
      @Consent bit
      
)

AS
SET NOCOUNT ON


insert into tblFlexFund(

ClientSIN,
ClientAppID,
Address,
City,
Postal,
Phone,
Phone2,
DateCreated,
DateRecv,
FirstApp,
FirstAppDate,
Agency_ID,
AmountR,
AmountF,
Approved,
ReasonRent,
ReasonUtil,
ReasonStart,
ChqPayName,
ChqPayAddress,
ChqPayCity,
ChqPayPostal,
ChqPayPhone,
ChqPayFax,
Explaination,
OtherAsst1,
OtherAsst2,
OtherAsst3,
Maintain,
Repayment,
NegotiatePay,
PlaceEmploy1,
Income1,
PlaceEmploy2,
Income2,
IncomeOW,
IncomeChild,
IncomeOther,
IncomeSupport,
IncomeOldAge,
TotalMonthlyIncome,
ExpRentMort,
ExpElec,
ExpHeat,
ExpWaterSew,
ExpPhone,
ExpCable,
ExpCar,
ExpLoansCC,
ExpOther,
OweRentMort,
OweElec,
OweHeat,
OweWaterSew,
OwePhone,
OweCable,
OweCar,
OweLoansCC,
OweOther,
TotalOwing,
TotalMonthly,
TotalIncome,
TotalExpenses,
MonthlyBalance,
PresentAddress,
PresentCity,
PresentPostal,
PresentLL,
PresLLAddress,
PresLLCity,
PresLLPostal,
PresLLPhone,
PresentUtil,
PresentRent,
PresentTime,
FutureAddress,
FutureCity,
FuturePostal,
FutureLL,
FutureLLAddress,
FutureLLCity,
FutureLLPostal,
FutureLLPhone,
FutureUtil,
FutureRent,
PrevAddress,
PrevCity,
PrevPostal,
PrevLL,
PrevLLAddress,
PrevLLCity,
PrevLLPostal,
PrevLLPhone,
HouseholdName1,
HouseholdAge1,
HouseholdRelation1,
HouseholdName2,
HouseholdAge2,
HouseholdRelation2,
HouseholdName3,
HouseholdAge3,
HouseholdRelation3,
HouseholdName4,
HouseholdAge4,
HouseholdRelation4,
HouseholdName5,
HouseholdAge5,
HouseholdRelation5,
HouseholdName6,
HouseholdAge6,
HouseholdRelation6,
HousingLivable,
Evicted,
RelateLL,
OtherInfo,
consent

)      
      
      values(
@ClientSIN,
@ClientAppID,
@Address,
@City,
@Postal,
@Phone,
@Phone2,
@DateCreated,
@DateRecv,
@FirstApp,
@FirstAppDate,
@Agency_ID,
@AmountR,
@AmountF,
@Approved,
@ReasonRent,
@ReasonUtil,
@ReasonStart,
@ChqPayName,
@ChqPayAddress,
@ChqPayCity,
@ChqPayPostal,
@ChqPayPhone,
@ChqPayFax,
@Explaination,
@OtherAsst1,
@OtherAsst2,
@OtherAsst3,
@Maintain,
@Repayment,
@NegotiatePay,
@PlaceEmploy1,
@Income1,
@PlaceEmploy2,
@Income2,
@IncomeOW,
@IncomeChild,
@IncomeOther,
@IncomeSupport,
@IncomeOldAge,
@TotalMonthlyIncome,
@ExpRentMort,
@ExpElec,
@ExpHeat,
@ExpWaterSew,
@ExpPhone,
@ExpCable,
@ExpCar,
@ExpLoansCC,
@ExpOther,
@OweRentMort,
@OweElec,
@OweHeat,
@OweWaterSew,
@OwePhone,
@OweCable,
@OweCar,
@OweLoansCC,
@OweOther,
@TotalOwing,
@TotalMonthly,
@TotalIncome,
@TotalExpenses,
@MonthlyBalance,
@PresentAddress,
@PresentCity,
@PresentPostal,
@PresentLL,
@PresLLAddress,
@PresLLCity,
@PresLLPostal,
@PresLLPhone,
@PresentUtil,
@PresentRent,
@PresentTime,
@FutureAddress,
@FutureCity,
@FuturePostal,
@FutureLL,
@FutureLLAddress,
@FutureLLCity,
@FutureLLPostal,
@FutureLLPhone,
@FutureUtil,
@FutureRent,
@PrevAddress,
@PrevCity,
@PrevPostal,
@PrevLL,
@PrevLLAddress,
@PrevLLCity,
@PrevLLPostal,
@PrevLLPhone,
@HouseholdName1,
@HouseholdAge1,
@HouseholdRelation1,
@HouseholdName2,
@HouseholdAge2,
@HouseholdRelation2,
@HouseholdName3,
@HouseholdAge3,
@HouseholdRelation3,
@HouseholdName4,
@HouseholdAge4,
@HouseholdRelation4,
@HouseholdName5,
@HouseholdAge5,
@HouseholdRelation5,
@HouseholdName6,
@HouseholdAge6,
@HouseholdRelation6,
@HousingLivable,
@Evicted,
@RelateLL,
@OtherInfo,
@consent    
)


set nocount off
GO

Thanks in advance for your help.
0
Question by:ClassyLinks
    11 Comments
     
    LVL 15

    Accepted Solution

    by:
    you can run the stored procedure from sql query analyzer...

    go to tools->object brower

    fild your stored procedure in the LHS menu and right click on your stored procedure and say open and enter the parameters and say execute...

    see if stored procedure works fine.
    0
     
    LVL 17

    Assisted Solution

    by:AerosSaga
    what is your   ClientID = request.querystring("id")

    coming through as?  
    0
     
    LVL 15

    Expert Comment

    by:praneetha
    Sub BindDataGrid(ClientID AS Integer)

                          dim GetContactCommand AS OleDBcommand= New OleDBCommand("Select * FROM tblclients WHERE tblClients.ApplicationID="& ClientID, Connect2)
                       
                          Dim Adapter AS OleDBDataAdapter = new OleDBDataAdapter
                          Adapter.Selectcommand = getContactCommand
                          Adapter.SelectCommand.Connection.Open

                          dim ContactDS AS DataSet = New DataSet
                          Adapter.Fill(ContactDS, "Contact")

                          ContactGrid.DataSource = ContactDS

                          Page.dataBind()// why does it say page.databind instead of contactgrid.databing
                  End Sub
          Page.dataBind()// why does it say page.databind instead of contactgrid.databing
    0
     
    LVL 15

    Expert Comment

    by:praneetha
     ClientID = request.querystring("id")
    i guess u should say   ClientID = request.querystring("id").ToString()
    0
     
    LVL 17

    Expert Comment

    by:AerosSaga
    again with the page.databind, lol;)
    0
     
    LVL 15

    Expert Comment

    by:praneetha
    i just learnt you can use page.databind instead of datagrid.databind...

    sorry about that
    0
     
    LVL 28

    Assisted Solution

    by:mmarinov
    Hi ClassyLinks,

    have you rebuild the code before tested it and receive this error - because i've checked and all parameters are ok

    Regards!
    B..M
    0
     
    LVL 25

    Assisted Solution

    by:nauman_ahmed
    ClassyLinks,

    Try adding

    Response.Write("testing")
    Response.End()

    at various places in the Button_Click and see which is the bad line in your code ;)

    Best, Nauman.

    0
     
    LVL 7

    Author Comment

    by:ClassyLinks
    OK, I tested praneetha's idea and ran the stored proc from the object browser and I was able to enter a record into the table, so I know there is nothing wrong with the sql side of things.  I also tried adding in the response.write statement and it still errors out at the same spot  "cmd.ExecuteNonQuery()" where the stored procedure is called.  

    Thanks for your help so far.

    Any other ideas?
    0
     
    LVL 7

    Author Comment

    by:ClassyLinks
    I found the problem....I was not using the correct variables when passing parameters back to the stored procedure for the last 4 in the list.  

                cmd.Parameters.Add("@HousingLivable", HousingLivable)
                cmd.Parameters.Add("@Evicted", Evicted)
                cmd.Parameters.Add("@RelateLL", RelateLL)
                cmd.Parameters.Add("@OtherInfo", OtherInfo)
                cmd.Parameters.Add("@Consent", Consent)
    should have been

        cmd.Parameters.Add("@HousingLivable", strHousingLivable)
                cmd.Parameters.Add("@Evicted", strEvicted)
                cmd.Parameters.Add("@RelateLL", strRelateLL)
                cmd.Parameters.Add("@OtherInfo", strOtherInfo)
                cmd.Parameters.Add("@Consent", strConsent)
    0
     
    LVL 15

    Expert Comment

    by:praneetha
    wow...good job ...good luck
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    This video Micro Tutorial is the second in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles a…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now