473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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 "WebsiteMetaKey words", adLongVarChar, 2147483647
testRS.Fields.A ppend "WebsiteMetaDes cription", adVarchar, 255
testRS.Fields.A ppend "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("Website ID") = RS2("WebsiteID" )
testRS("Website Name") = RS2("WebsiteNam e")
testRS("Website Desc") = RS2("WebsiteDes c")
testRS("Website URL") = RS2("WebsiteURL ")
testRS("Website MetaKeywords") = RS2("WebsiteMet aKeywords")
testRS("Website MetaDescription ") = RS2("WebsiteMet aDescription")
testRS("Relevan ce") = 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 1966

soz, resolved this one now, it seems i needed to put a testRS.MoveFirs t
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.filte r = 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********@N O-SPAM.kingswoodw eb.net> wrote in message
news:Ib******** ***********@new s-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.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 "WebsiteMetaKey words", adLongVarChar, 2147483647
testRS.Fields.A ppend "WebsiteMetaDes cription", adVarchar, 255
testRS.Fields.A ppend "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("Website ID") = RS2("WebsiteID" )
testRS("Website Name") = RS2("WebsiteNam e")
testRS("Website Desc") = RS2("WebsiteDes c")
testRS("Website URL") = RS2("WebsiteURL ")
testRS("Website MetaKeywords") = RS2("WebsiteMet aKeywords")
testRS("Website MetaDescription ") = RS2("WebsiteMet aDescription")
testRS("Relevan ce") = 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********@N O-SPAM.kingswoodw eb.net> wrote in message
news:Ib******** ***********@new s-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.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 "WebsiteMetaKey words", adLongVarChar, 2147483647
testRS.Fields.A ppend "WebsiteMetaDes cription", adVarchar, 255
testRS.Fields.A ppend "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("Website ID") = RS2("WebsiteID" )
testRS("Website Name") = RS2("WebsiteNam e")
testRS("Website Desc") = RS2("WebsiteDes c")
testRS("Website URL") = RS2("WebsiteURL ")
testRS("Website MetaKeywords") = RS2("WebsiteMet aKeywords")
testRS("Website MetaDescription ") = RS2("WebsiteMet aDescription")
testRS("Relevan ce") = 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
1789
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 relevance for search results which gets the row from the recordset, strips out the html tags, then does its magic to produce the 'relevance' for that row.
4
3092
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 the recordset to loop thru the recordset, update values from the recordset and then update the database by passing parmeters to another stored procedure. I would like to use the recordset object but can it be used to pass a parameter to a stored...
1
4314
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
29848
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 Long) As Boolean Dim rsAssignedUser As ADODB.Recordset Dim strSelectUser As String
2
2328
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 property during the Open event. According to the VBA Help file, setting the Recordset property may adjust the RecordSource property accordingly. If I set the RecordSource to blank in Design mode, it remains blank when the form is opened even...
2
3421
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 this syntax: rs.Open(sPathToXMLfile) When incorporating his code in my C# app, the ADODB.Recordset Open method takes 5 arguments, all required. VB.NET arguments are, I assume, optional since they are in square brackets.
36
4483
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
4
1510
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 Server database and parses some of the data and puts the parsed data into a text field. I omitted a some of the code and left the data parsing part of it, which is what my question is about. Exactly what the code below does is gets data from SQL...
7
2282
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 from table 1 into a recordset using the following strSQL_in = "select * from table1" ( and i can refer to the columns as needed)
4
2716
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 code that calculates the total price, depending on number of units, currently what the code does is set the price like so - if qty 1 then £99+VAT if qty equall to or greater than 2 and equall to or less than 9 then price =
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.