Solved

one dataset table to multiple dataset table...

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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