Click here to Skip to main content
15,897,187 members
Home / Discussions / Database
   

Database

 
GeneralRe: read & update using reader Pin
Pete O'Hanlon13-Dec-10 11:15
mvePete O'Hanlon13-Dec-10 11:15 
GeneralRe: read & update using reader Pin
PIEBALDconsult13-Dec-10 13:53
mvePIEBALDconsult13-Dec-10 13:53 
GeneralRe: read & update using reader Pin
Gary Huck13-Dec-10 23:56
Gary Huck13-Dec-10 23:56 
GeneralRe: read & update using reader Pin
James Lonero15-Dec-10 14:00
James Lonero15-Dec-10 14:00 
AnswerRe: read & update using reader Pin
Brady Kelly13-Dec-10 23:24
Brady Kelly13-Dec-10 23:24 
AnswerRe: read & update using reader Pin
Gary Huck13-Dec-10 23:51
Gary Huck13-Dec-10 23:51 
GeneralRe: read & update using reader Pin
PIEBALDconsult15-Dec-10 2:20
mvePIEBALDconsult15-Dec-10 2:20 
AnswerRe: read & update using reader Pin
Spectre_00114-Dec-10 1:48
Spectre_00114-Dec-10 1:48 
You can not update through a DataReader. It retreives a read-only, forward-only stream of data one record at a time.

If I read your question correctly, you are doing some processing on each record after reading, then need to set a flag in the database to indicate that record has been processed.

You will need a second connection and comand object for this. You can't use the same connection/command as the DataReader because it keeps it's connection open internally throughout it's lifetime.

The best way to accomplish this will vary slightly depending on how many records you expect to process and whether the processing will run a long time (cumulative).

For a relatively short run:
1. Open SQLConnection for updating and attach to SQLCommand
2. Read next record from DataReader
3. Perform needed processing
4. Generate update SQL for current record
5. Use SQLCommand to run update SQL
6. Repeat steps 2 - 5 until last record has been processed and updated
7. Close and destroy update SQLConnection/SQLCommand

For a long run:
1. Create SQLConnection for updating and attach to SQLCommand
2. Read next record from DataReader
3. Perform needed processing
4. Generate update SQL for current record
5. Open SQLConnection for update
6. Use SQLCommand to run update SQL
7. Close SQLConnection
8. Repeat 2 - 7 until last record has been processed and updated
9. Close and destroy update SQLConnection/SQLCommand

Hope this answers your question and helps out.
Kevin Rucker, Application Programmer
QSS Group, Inc.
United States Coast Guard OSC
Kevin.D.Rucker@uscg.mil

"Programming is an art form that fights back." -- Chad Hower

GeneralRe: read & update using reader Pin
PIEBALDconsult15-Dec-10 2:22
mvePIEBALDconsult15-Dec-10 2:22 
GeneralRe: read & update using reader Pin
Spectre_00115-Dec-10 2:27
Spectre_00115-Dec-10 2:27 
AnswerRe: read & update using reader Pin
Jason Christian14-Dec-10 8:44
Jason Christian14-Dec-10 8:44 
Questionconverting column values to column. [modified] Pin
livewire1310-Dec-10 18:39
livewire1310-Dec-10 18:39 
AnswerRe: converting column values to column. Pin
Kasson10-Dec-10 20:29
Kasson10-Dec-10 20:29 
AnswerRe: converting column values to column. Pin
thatraja10-Dec-10 20:32
professionalthatraja10-Dec-10 20:32 
AnswerRe: converting column values to column. Pin
Goutam Patra10-Dec-10 21:08
professionalGoutam Patra10-Dec-10 21:08 
AnswerRe: converting column values to column. Pin
Mycroft Holmes11-Dec-10 20:28
professionalMycroft Holmes11-Dec-10 20:28 
AnswerRe: converting column values to column. Pin
RaviRanjanKr20-Dec-10 18:22
professionalRaviRanjanKr20-Dec-10 18:22 
QuestionHow to convert varchar values to int while passing as an in parameter? Pin
meeram39510-Dec-10 0:25
meeram39510-Dec-10 0:25 
AnswerRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39510-Dec-10 0:40
meeram39510-Dec-10 0:40 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
Hiren solanki10-Dec-10 1:33
Hiren solanki10-Dec-10 1:33 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39512-Dec-10 19:14
meeram39512-Dec-10 19:14 
AnswerRe: How to convert varchar values to int while passing as an in parameter? Pin
Eddy Vluggen10-Dec-10 0:59
professionalEddy Vluggen10-Dec-10 0:59 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
PIEBALDconsult10-Dec-10 2:43
mvePIEBALDconsult10-Dec-10 2:43 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
Eddy Vluggen10-Dec-10 4:55
professionalEddy Vluggen10-Dec-10 4:55 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39512-Dec-10 19:14
meeram39512-Dec-10 19:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.