473,386 Members | 1,757 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,386 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 1947

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.