Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

one dataset table to multiple dataset table...

Posted on 2006-11-17
6
Medium Priority
?
190 Views
Last Modified: 2008-02-01
Hi,
I have a dataset datatable
select ORDER ,
DESCRIPTION,
FIRSTNAME,
LASTNAME,
ADDRESS,
ZIP
FROM Order
               I need to select only FIRSTNAME,LASTNAME,ADDRESS,ZIP and insert in to new table called CONTACTS which has identity column CONTACTKEY. Then i need to select order and description and insert in to new table ORDERS which has ORDERID as identity column with one more column CONTACTKEY which has a foreignkey relationship to order table so when i am inserting the rows for orders the same contactkey should be updated in to ORDERS table as we have the releationship then i need to insert into database
how to do that?
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_22062573.html

Regards
Nanban
0
Comment
Question by:nanban
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971043
Create an insert statement for the contacts table insert into contacts (FIRSTNAME,LASTNAME,ADDRESS,ZIP) values (FIRSTNAME,LASTNAME,ADDRESS,ZIP).
Then get the identity that was created for that insert.
You can either do this by running Select @@IDENTITY which will get you the value of CONTACTKEY most recently created or, if your database does not support @@IDENTITY, do select Max(CONTACTKEY) from CONTACTS and that should get you the same value.

Now you have your contactkey value you can use it in the insert statement into the orders table.
0
 

Author Comment

by:nanban
ID: 17976858
I dont want to use insert statement. I want to select particular column from the dataset which has all the columns. how to do that?
0
 

Author Comment

by:nanban
ID: 18136798
The Problem is resolved
1.This is the one of the way to insert relational data
http://www.codeproject.com/cs/database/relationaladonet.asp?df=100&forumid=14883&exp=0&select=1113044

2. Another way is using enterprise libaray updatedataset method.
using updatedataset its not requires to insert record one by one. After setting the relation between the table (primarykey foreignkey) using datarelation, first insert the table which needs to return identity column value using stored procedure then insert the table which needs the value from previous insert. it will automatically update the column with the returned value.

Regards,
Nanban.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18171235
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question