472,794 Members | 2,221 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Insert records into database based on query

I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records

user1 file1 group1
user1 file2 group1

I would then like to insert records into the table based
on the datareader but change the last field to the
following

user1 file1 group2
user1 file2 group2

The final result in the table should then be
user1 file1 group1
user1 file2 group1
user1 file1 group2
user1 file2 group2

I have tried looping through the datareader and doing a
insert via executenonquery. I have also tried using a
dataset and adding to the dataset.

Any help with this issue will be much appreciated
Nov 17 '05 #1
3 1792
You haven't explained what the problem is with your solutions.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andrew Bourne" <ab*****@cogeco.ca> wrote in message
news:0a****************************@phx.gbl...
I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records

user1 file1 group1
user1 file2 group1

I would then like to insert records into the table based
on the datareader but change the last field to the
following

user1 file1 group2
user1 file2 group2

The final result in the table should then be
user1 file1 group1
user1 file2 group1
user1 file1 group2
user1 file2 group2

I have tried looping through the datareader and doing a
insert via executenonquery. I have also tried using a
dataset and adding to the dataset.

Any help with this issue will be much appreciated

Nov 17 '05 #2
Hi Kevin,

Thanks for responding. I have managed to sort out the
problem by returning the datareader results into a
sortedlist array. (The Keys are unique) I then iterate
through the sortedlist and insert the records into the
database.

Thanks

Andrew
-----Original Message-----
You haven't explained what the problem is with your solutions.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andrew Bourne" <ab*****@cogeco.ca> wrote in message
news:0a****************************@phx.gbl...
I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records

user1 file1 group1
user1 file2 group1

I would then like to insert records into the table based on the datareader but change the last field to the
following

user1 file1 group2
user1 file2 group2

The final result in the table should then be
user1 file1 group1
user1 file2 group1
user1 file1 group2
user1 file2 group2

I have tried looping through the datareader and doing a
insert via executenonquery. I have also tried using a
dataset and adding to the dataset.

Any help with this issue will be much appreciated

.

Nov 17 '05 #3
Hi Kevin,

Thanks for responding. I have managed to sort out the
problem by returning the datareader results into a
sortedlist array. (The Keys are unique) I then iterate
through the sortedlist and insert the records into the
database.

Thanks

Andrew
-----Original Message-----
You haven't explained what the problem is with your solutions.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andrew Bourne" <ab*****@cogeco.ca> wrote in message
news:0a****************************@phx.gbl...
I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records

user1 file1 group1
user1 file2 group1

I would then like to insert records into the table based on the datareader but change the last field to the
following

user1 file1 group2
user1 file2 group2

The final result in the table should then be
user1 file1 group1
user1 file2 group1
user1 file1 group2
user1 file2 group2

I have tried looping through the datareader and doing a
insert via executenonquery. I have also tried using a
dataset and adding to the dataset.

Any help with this issue will be much appreciated

.

Nov 17 '05 #4

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

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
2
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
6
by: efgh | last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards with an Insert Into statement in Access 2003. I've got a 4 column table that I've simplified about as much as I can, no...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
8
by: nano2k | last post by:
Hi Shortly, I keep invoices in a table. Occasionally, someone will fire the execution of a stored procedure (SP) that performs several UPDATEs against (potentially) all invoices OLDER than a...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
5
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.