473,216 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Recordset Question

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


Jul 19 '05 #1
5 1939

soz, resolved this one now, it seems i needed to put a testRS.MoveFirst
after adding the rows to get back to the start...

Rob
Jul 19 '05 #2
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" <ro********@NO-SPAM.kingswoodweb.net> wrote in message
news:Ib*******************@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

Jul 19 '05 #3
> testRS.AddNew

UGH!

Use an INSERT statement.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #4
Of course, I didn't read it all... why don't you use an array or a
dictionary instead of a recordset?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Rob Meade" <ro********@NO-SPAM.kingswoodweb.net> wrote in message
news:Ib*******************@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

Jul 19 '05 #5
"Aaron Bertrand - MVP" wrote ...
Of course, I didn't read it all... why don't you use an array or a
dictionary instead of a recordset?


Lo Aaron,

I wouldnt normally use the AddNew/Update stuff, haven't used it in ages, but
found I needed to here, with regards to the array, I needed to be able to
create a recordset and add a 'phantom' field, then after updating this field
for each record be able to sort it into ascending order (the relevance stuff
for the search results) - once sorted its then dumped to the page.

I looked at sorted the arrays but it seemed to all come back to using a
recordset anyway, so I've gone with that for now...

I guess I could have probably used a temporary table in SQL Server maybe,
but I've not used them before and the site this is for is quite a busy one,
therefore I didnt think that creating a multitude of temp tables was a good
idea, I could of course be wrong as I say, I've not done/tried that before
to know.

Regards

Rob
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob Meade | last post by:
Lo all, I have a local recordset which is not linked to a database. Some of the fields in this recordset contain html tags. I have a function which is called when I'm calculating my...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
1
by: Tom Lee | last post by:
Hi Guys, Firstly thanks for all the help you have providing me... I have another question I was stuck with. Here is a simple code dim strsql as string dim scr as recordset
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
2
by: Lyn | last post by:
Hi, I am opening a form in Continuous mode to list the records from a recordset created in the calling form. The recordset object is declared as Public and is set into the new form's Recordset...
2
by: Marathoner | last post by:
I have read Bill Vaughn's paper on this subject and I have one stumbling block. Bill wrote his demo in VB.NET. He converts a DataTable to an XML file. In VB.NET, he dimmed a recordset and used...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
4
by: Joseph | last post by:
Hi all- I am a former VB6 programmer and new at C# and I have a question dealing with converting some code from VB6 to C#. The code is below and essentially, what it does is gets data from a SQL...
7
by: tdr | last post by:
I need to compare table 1 to table 2 and if the row/recordset in table 1 is different from table 2, write the entire row/recordset from table 1 to table 3. I can read an entire row/recordset ...
4
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I think I'm done for now,... Is it possible to insert recordset data in a javascript, for instance I have a javascript...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.