Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 13th, 2003, 05:52 AM
shafan's Avatar
shafan shafan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 123 shafan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 51 sec
Reputation Power: 7
Adding a Field to a populated ado recordset :: RESOLVED

Hi,
I'm trying to add a field to an already populated ado recordset.
The problem is that in order to add the field I need to close the recordset, which causes the loss of all the records in it.

Help would be appreciated

Last edited by shafan : May 15th, 2003 at 01:45 AM.

Reply With Quote
  #2  
Old May 15th, 2003, 01:30 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Smile

How is the rs being stored ? i.e. what db format

Can you open up the db and add the field manually, rather than through ADO commands.

Also - have a look at Devguru - ADO
__________________
How can I soar like an eagle when
I'm flying with turkey's?

Reply With Quote
  #3  
Old May 15th, 2003, 01:45 AM
shafan's Avatar
shafan shafan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 123 shafan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 51 sec
Reputation Power: 7
I've resolved it by creating a dummy field in the database

Reply With Quote
  #4  
Old May 15th, 2003, 01:46 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
well done...

Reply With Quote
  #5  
Old February 5th, 2004, 01:56 PM
Johnnycrash Johnnycrash is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 Johnnycrash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You cant do Fields.Add, but as long as there is a field in the db of the right type, you can select it in your query and use it as an "added field" - as long as you detach the recordset. Detach the recordset so you can update the temp field without changing the db. This assumes you ar not using the recordset to update the database....

Lets say my program uses a recordset and I need to hold temp data for each record.

vb psuedo code:


sSQL = "SELECT SomeIntegerField as Temp, * FROM SomeTable"
rs.Open sSQL, Ado, adOpenDynamic, adLockBatchOptimistic
Set rs.ActiveConnection = Nothing
rs.MoveFirst
Do While Not rs.EOF
rs!Temp = Some calculation or whatever
rs.MoveNext
Loop

do whatever I want with rs!temp throughout the program


I don't know if adOpenDynamic is the only type of recordset this works with. I do know that adLockReadOnly will not work.

Also Temp and SomeIntegerField (because * was used, SomeIntegerField will be available in the above example) are independent - Temp is not an alias - so they can have separate values in them.




You can

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Adding a Field to a populated ado recordset


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT