p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   Update DB by passing ID number (http://p2p.wrox.com/showthread.php?t=56537)

jonsey April 11th, 2007 11:30 AM

Update DB by passing ID number
 
What I'm doing is pulling data into my form by a ID number. What I need to do is update two table in the DB here is what I have so far. I keep getting this error message:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment: 'UpdateSurvey'

/WorkSheet.asp, line 83

Line 83 or the worksheet is:
vSurveyID = objData.UpdateSurvey()

I'm passing the vSurveyID form another page example:
WorkSheet.asp?Store=1234&SurveyID=226

I know store and survey id are work becuase I able to import my data to the form it is just when I go back out to save the changes it is not passing the vSurveyID to it.

Any help would be great thanks in Advance.

Jonsey


Code:
If Request("SurveyID") <> "" Then

        vSurveyID = Request("SurveyID")

End If



ASP VBScript Code:

If Request.Form("action") = "Save Form Data" Then
    ' Do our DB insert!


        Dim objData
        Set objData = New clsUpdateData
        Dim vSurveyID

        Dim SurveyUpdateUser, SurveyUpdateDate,_
            AnswerGroupNumber, AnswerGroupWeight,_
            AnswerQuestionNumber, AnswerQuestionWeight,_
            AnswerValue, AnswerComment ' Dim Form Elements for writing to DB


        vSurveyID = objData.UpdateSurvey()

        SurveyUpdateUser = Request.ServerVariables("AUTH_USER")
        SurveyUpdateDate = FormatDateTime(Now(),0)


            For lGroup = 0 to oXml.SelectNodes("//root/group").Length - 1
                Set oGroup = oXml.SelectNodes("//root/group").Item(lGroup)

                For lQuestion = 0 to oGroup.SelectNodes("question").Length - 1
                    Set oQuestion = oGroup.SelectNodes("question").Item(lQuestion)

                        AnswerGroupNumber = Request.Form("AnswerGroupNumber_" & lGroup & "_" & lQuestion)
                        AnswerGroupWeight = Request.Form("AnswerGroupWeight_" & lGroup & "_" & lQuestion)
                        AnswerQuestionNumber = Request.Form("AnswerQuestionNumber_" & lGroup & "_" & lQuestion)
                        AnswerQuestionWeight = Request.Form("AnswerQuestionWeight_" & lGroup & "_" & lQuestion)
                        AnswerValue = Request.Form("AnswerValue_" & lGroup & "_" & lQuestion)
                        AnswerComment = Request.Form("AnswerComment_" & lGroup & "_" & lQuestion)

                        Call objData.UpdateAnswer( _
                            vSurveyID, _
                            0, _
                            AnswerGroupNumber, _
                            AnswerGroupWeight, _
                            AnswerQuestionNumber, _
                            AnswerQuestionWeight, _
                            AnswerValue, _
                            AnswerComment _
                            )
            Next
        Next


Class code:

Class clsUpdateData

        Dim objConn

        Private Sub Class_Initialize()
        End Sub

        Private Sub Class_Terminate()
        End Sub



        Public Function UpdateSurvey(pSurveyID) ' As Long

            Dim vSQL
            vSQL = Reusables.ReadAllFromFile(Server.MapPath("/lib/sql/clsData/UpdateSurvey.sql"))
            vSQL Replace(vSQL, "##pSurveyID##", "pSurveyID")

            Debug.PrintTA vSQL

            Set objRS = Server.CreateObject("ADODB.RecordSet")
            Call objRS.Open(vSQL, VZWApp.Setting("ConnectString"), adOpenKeyset, adLockOptimistic)

            With objRS

                .Update()
                    .Fields("SurveyUpdateDate") = Now()
                    .Fields("SurveyUpdateUser") = Request.ServerVariables("AUTH_USER")
                    .Fields("SurveyOutletID") = Request.Form("SurveyOutletID")
                .Update()

                UpdateSurvey = .Fields("SurveyID")

                Call .Close()

            End With

            Set objRS = Nothing

        End Function

        Public Function UpdateAnswer( _
            pSurveyID, _
            pFormVersionID, _
            pAnswerGroupNumber, _
            pAnswerGroupWeight, _
            pAnswerQuestionNumber, _
            pAnswerQuestionWeight, _
            pAnswerValue, _
            pAnswerComment _
            ) ' As Long

            Dim vSQL
            vSQL = Reusables.ReadAllFromFile(Server.MapPath("/lib/sql/clsData/UpdateAnswer.sql"))
            vSQL Replace(vSQL, "##pSurveyID##", "pSurveyID")

            Set objRS = Server.CreateObject("ADODB.RecordSet")
            Call objRS.Open(vSQL, VZWApp.Setting("ConnectString"), adOpenKeyset, adLockOptimistic)

            With objRS

                .Update()
                    .Fields("FormVersionID") = pFormVersionID
                    .Fields("AnswerGroupNumber") = pAnswerGroupNumber
                    .Fields("AnswerGroupWeight") = pAnswerGroupWeight
                    .Fields("AnswerQuestionNumber") = pAnswerQuestionNumber
                    .Fields("AnswerQuestionWeight") = pAnswerQuestionWeight
                    .Fields("AnswerValue") = pAnswerValue
                    .Fields("AnswerComment") = pAnswerComment
                .Update()

                AddAnswer = .Fields("AnswerID")

                Call .Close()

            End With

            Set objRS = Nothing

        End Function



    End Class





mat41 April 11th, 2007 07:05 PM

You should look at the number of arguments in your function call. Have you googles this? There is so so so so much information on this very common error.

You even have 2 pages of results within this forums search:
http://p2p.wrox.com/search.asp?mode=...gnment&x=9&y=9

Wind is your friend
Matt


All times are GMT -4. The time now is 03:22 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.