Solved

one dataset table to multiple dataset table...

Posted on 2006-11-17
6
183 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now