Problem updating this recordset...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Meade

    Problem updating this recordset...

    Lo all,

    I'm having a little bit of trouble (betty...).

    I have removed some of the obvious stuff from this example (like connections
    being opened/closed etc)

    I create a recordset in ASP (not linked to a database)

    Set testRS = Server.CreateOb ject("ADODB.Rec ordSet")
    testRS.Fields.A ppend "WebsiteID" , adInteger
    testRS.Fields.A ppend "WebsiteNam e", adVarchar, 20
    testRS.Fields.A ppend "WebsiteDes c", adVarchar, 255
    testRS.Fields.A ppend "WebsiteURL ", adVarchar, 255
    testRS.Fields.A ppend "Relevance" , adInteger

    testRS.Open

    I then iterate through a secondset recordset (linked to a database) and dump
    in all of my rows of data into my 'local' recordset.

    Do While Not RS2.EOF

    testRS.AddNew

    testRS("Website ID") = RS2("WebsiteID" )
    testRS("Website Name") = RS2("WebsiteNam e")
    testRS("Website Desc") = RS2("WebsiteDes c")
    testRS("Website URL") = RS2("WebsiteURL ")
    testRS("Relevan ce") = RS2("Relevance" )

    testRS.Update

    RS2.MoveNext
    Loop

    I now iterate through my local recordset and populate an array and look for
    words with the string for each field (calling the GetSubstringCou nt
    function)

    Dim aFields(3)
    testRS.MoveFirs t

    Do While Not testRS.EOF

    aFields(0) = testRS("Website Name")
    aFields(1) = testRS("Website Desc")
    aFields(2) = testRS("Website MetaKeywords")
    aFields(3) = testRS("Website MetaDescription ")

    iCount = 0

    For intLoop = 0 To UBound(aSearchC riteria)

    For intLoop2 = 0 To UBound(aFields)

    iCount = iCount + GetSubstringCou nt(aFields(intL oop2),
    aSearchCriteria (intLoop), False)

    Next

    Next

    testRS("Relevan ce") = iCount
    testRS.Update

    intTotalRelevan ce = intTotalRelevan ce + iCount

    testRS.MoveNext
    Loop

    Ok - so thats pretty much the code, now then - my 'revelance' field for each
    row needs to be a numeric value, initially I'd set this to be a Integer then
    realised that I would get 12.35 as a result etc, so had a quick look at the
    constants for the ado stuff and saw the adNumeric - which according to this
    page :



    can be used for the SQL Server version of Numeric/Decimal - so I figured I'd
    use that...

    So I've changed the above field appends to this :

    Set testRS = Server.CreateOb ject("ADODB.Rec ordSet")
    testRS.Fields.A ppend "WebsiteID" , adInteger
    testRS.Fields.A ppend "WebsiteNam e", adVarchar, 20
    testRS.Fields.A ppend "WebsiteDes c", adVarchar, 255
    testRS.Fields.A ppend "WebsiteURL ", adVarchar, 255
    testRS.Fields.A ppend "Relevance" , adNumeric

    But now everytime it runs I get this error :

    Microsoft Cursor Engine error '80040e21'

    Multiple-step operation generated errors. Check each status value.

    /parasolit/statics/mainbody-search-results.asp, line 708

    Line 708 is the line which tries to do this :

    testRS("Relevan ce") = iCount

    followed by

    testRS.Update

    When I leave it set as an integer its fine works ok but I dont get the
    decimals, when I change it to numeric it goes tits up....

    What I am trying to achieve is the population of at percentage value in
    there - so if it goes and finds a couple of results they may be stored in
    the local recordset (ready to dump to the page) like so :

    58.35
    41.65

    etc etc

    Can anyone see where I'm going wrong - I can post the entire page of code if
    you want but its quite big and has lots of extra stuff not really relevant
    to this problem.

    Any info appreciated,

    Regards

    Rob


  • Rob Meade

    #2
    Re: Problem updating this recordset...

    "Rob Meade" wrote ...

    [..snip..]

    Incidentally, I do realise I could change it to a varchar and it would
    probably accept the values but because I want to sort this column later I
    assumed that I might get something like this :

    1
    2
    3
    33
    4
    5
    6
    66
    67
    68
    7

    etc, based on it being text rather than

    1
    2
    3
    5
    6
    7
    33
    66
    67
    68

    Regards

    Rob


    Comment

    • Bob Barrows [MVP]

      #3
      Re: Problem updating this recordset...

      Rob Meade wrote:[color=blue]
      >
      > http://www.able-consulting.com/ADODataTypeEnum.htm
      >
      > can be used for the SQL Server version of Numeric/Decimal - so I
      > figured I'd use that...
      >
      > So I've changed the above field appends to this :
      >
      > testRS.Fields.A ppend "Relevance" , adNumeric
      >[/color]
      You need to set the NumericScale and Precision properties of the Field
      separately when using adNumeric or adDecimal:

      testRs("Relevan ce").Precision= 5
      testRs("Relevan ce").NumericSca le = 2

      HTH,
      Bob Barrows
      --
      Microsoft MVP -- ASP/ASP.NET
      Please reply to the newsgroup. The email account listed in my From
      header is my spam trap, so I don't check it very often. You will get a
      quicker response by posting to the newsgroup.


      Comment

      • Rob Meade

        #4
        Re: Problem updating this recordset...

        "Bob Barrows [MVP]" wrote...
        [color=blue]
        > You need to set the NumericScale and Precision properties of the Field
        > separately when using adNumeric or adDecimal:
        >
        > testRs("Relevan ce").Precision= 5
        > testRs("Relevan ce").NumericSca le = 2[/color]

        I so wish this stuff was in my vbScripts book!!!

        Where do I add that then Bob - near the field appends?

        Regards

        Rob


        Comment

        • Rob Meade

          #5
          Re: Problem updating this recordset...

          "Bob Barrows [MVP]" wrote ...
          [color=blue]
          > You need to set the NumericScale and Precision properties of the Field
          > separately when using adNumeric or adDecimal:
          >
          > testRs("Relevan ce").Precision= 5
          > testRs("Relevan ce").NumericSca le = 2[/color]

          Hello again Bob,

          thanks for that, I've added it beneath my code for the append.fields stuff,
          just ran it and it works perfectly - :o)

          Can you now tell me what they do :oD

          I'm 'guessing' that numeric scale is for 2 decimal places - not sure about
          the precision....

          Thanks again

          Rob


          Comment

          • Rob Meade

            #6
            Dont worry....

            Just found this looking for something else- lol...


            "Rob Meade" <robert.meade@N OSPAMubht.swest .nhs.uk> wrote in message
            news:eYbg%23yj8 DHA.2332@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > "Bob Barrows [MVP]" wrote...
            >[color=green]
            > > You need to set the NumericScale and Precision properties of the Field
            > > separately when using adNumeric or adDecimal:
            > >
            > > testRs("Relevan ce").Precision= 5
            > > testRs("Relevan ce").NumericSca le = 2[/color]
            >
            > I so wish this stuff was in my vbScripts book!!!
            >
            > Where do I add that then Bob - near the field appends?
            >
            > Regards
            >
            > Rob
            >
            >[/color]


            Comment

            • Bob Barrows [MVP]

              #7
              Re: Problem updating this recordset...

              Rob Meade wrote:[color=blue]
              > "Bob Barrows [MVP]" wrote...
              >[color=green]
              >> You need to set the NumericScale and Precision properties of the
              >> Field separately when using adNumeric or adDecimal:
              >>
              >> testRs("Relevan ce").Precision= 5
              >> testRs("Relevan ce").NumericSca le = 2[/color]
              >
              > I so wish this stuff was in my vbScripts book!!![/color]

              It's not really vbscript: it's ADO. It's not surprising (to me, anyways)
              that a vbscript book would not cover this.

              ADO documentation is at msdn.microsoft. com/library - here's a link to the
              starting point:
              Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.


              Make sure you look up these properties so you understand what they do.
              [color=blue]
              >
              > Where do I add that then Bob - near the field appends?
              >[/color]
              Yep. Actually, any time between the creation of the Field object and the
              first attempt to add data to it.

              Bob Barrows
              --
              Microsoft MVP -- ASP/ASP.NET
              Please reply to the newsgroup. The email account listed in my From
              header is my spam trap, so I don't check it very often. You will get a
              quicker response by posting to the newsgroup.


              Comment

              • Rob Meade

                #8
                Re: Problem updating this recordset...

                "Bob Barrows [MVP]" wrote ...
                [color=blue]
                > It's not really vbscript: it's ADO. It's not surprising (to me, anyways)
                > that a vbscript book would not cover this.
                >
                > ADO documentation is at msdn.microsoft. com/library - here's a link to the
                > starting point:
                > http://msdn.microsoft.com/library/en...dooverview.asp
                >
                > Make sure you look up these properties so you understand what they do.
                >[color=green]
                > >
                > > Where do I add that then Bob - near the field appends?
                > >[/color]
                > Yep. Actually, any time between the creation of the Field object and the
                > first attempt to add data to it.[/color]

                Many thanks again Bob :o)

                Regards

                Rob


                Comment

                Working...