Re: Recordset Question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Manohar Kamath [MVP] (mkamath_at_TAKETHISOUTkamath.com)
Date: 02/09/04


Date: Mon, 9 Feb 2004 16:05:07 -0600

You need to create fields only once, but you need to use .AddNew everytime
you want to add a new record, and do an Update once you are done.

I am not sure which recordset should have two records, but you can do a
recordset.filter = vbNullString to reset the cursor back to the first
record. I am guessing the cursor is at the second record when it begins to
iterate.

-- 
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Rob Meade" <robb.meade@NO-SPAM.kingswoodweb.net> wrote in message
news:IbTVb.605$D%2.5172414@news-text.cableinet.net...
> evenin'
>
> k - I've got a recordset that I'm dumping another recordset into - because
> the source comes from a database that I cant update (probably makes more
> sense to me that bit) - anyway, I need to update the new recordset which I
> can do...I think however that I have missed something, as later in my code
> it only seems to iterate once, and there should be at least 2 rows in the
> recordset...
>
> Can anyone confirm that when I use something like this :
>
>    Set testRS = Server.CreateObject("ADODB.RecordSet")
>    testRS.Fields.Append "WebsiteID", adInteger
>    testRS.Fields.Append "WebsiteName", adVarchar, 20
>    testRS.Fields.Append "WebsiteDesc", adVarchar, 255
>    testRS.Fields.Append "WebsiteURL", adVarchar, 255
>    testRS.Fields.Append "WebsiteMetaKeywords", adLongVarChar, 2147483647
>    testRS.Fields.Append "WebsiteMetaDescription", adVarchar, 255
>    testRS.Fields.Append "Relevance", adInteger
>
> I do this initially before using addNew etc
>
> Then for each row that I want to add  I'd use something like this :
>
>     testRS.AddNew
>
>     testRS("WebsiteID") = RS2("WebsiteID")
>     testRS("WebsiteName") = RS2("WebsiteName")
>     testRS("WebsiteDesc") = RS2("WebsiteDesc")
>     testRS("WebsiteURL") = RS2("WebsiteURL")
>     testRS("WebsiteMetaKeywords") = RS2("WebsiteMetaKeywords")
>     testRS("WebsiteMetaDescription") = RS2("WebsiteMetaDescription")
>     testRS("Relevance") = RS2("Relevance")
>
>     testRS.Update
>
> (RS2 in the above is the source recordset incidentally - I have a do while
> not rs2.eof around this)...
>
> Just seeking some confirmation that i dont need to do the append fields
bit
> for each iteration...
>
> Cheers
>
> Rob
>
>
>
>


Relevant Pages

  • Re: OLEDB, stacked views, and efficiency
    ... way to iterate through a Table to get data. ... filter a Recordset in Access. ... Saved Query. ...
    (microsoft.public.data.oledb)
  • Re: OLEDB, stacked views, and efficiency
    ... > size of the returned recordset BEFORE I start to iterate it? ... > size of the returned recordset when I filter it, ...
    (microsoft.public.data.oledb)
  • Re: Reset Identity Fields or Foreach Ado.Net Schema Rowset
    ... Why not use a DataFlow to query sys.tables to get the names of the tables into a Recordset destinationand then iterate over that instead. ... collection restrictions. ...
    (microsoft.public.sqlserver.dts)
  • Re: submatches
    ... One way would be to open and iterate through a recordset. ... Set rsR = CurrentDB.OpenRecordset ... >>>account number, ...
    (microsoft.public.access.modulesdaovba)
  • Re: OLEDB, stacked views, and efficiency
    ... Open a rowset with the above SQL statement with MS client ... > I will create a recordset using a standard SELECT/JOIN query. ... At this point I will iterate the recordset to retrieve my data. ... > Just want to know before I tackle filters and views in a big way ... ...
    (microsoft.public.data.oledb)