Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
(Parent Grid) Doc_No                            (ChildGrid) Material  Quantity
              112233                                        Pipes       8
                                                            cubes       10
                                                            Piping      20
 
              123125                                        Pipes       5
                                                            Rcc         2
 
Doc_No is taken from DB, Material,Quantity is from temparory DataTable(material,Quantity).
Now,my question is to inser Parent Grid Doc_No into my temparory DataTable
 
like this.
Temprory DataTable
 
Doc_No     Material        Quantity
112233     Pipes           8
112233     cubes           10
......
 
How to do this can anyone help me to solve this issue....
 
Thanks in advance....
Posted 28-Sep-12 23:08pm
Edited 30-Sep-12 18:55pm
v2
Comments
Sandeep Mewara at 29-Sep-12 9:35am
   
Is the column Doc_no defined in temp table?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Probably you don't need to use temporary table, you can use simple SELECT query. If the data are stored in two different tables, like Document and Document_Details and they are related by Doc_No, you can use something like this:
SELECT D.Doc_No, DD.Material, DD.Quantity
FROM Document AS D
    LEFT JOIN Document_Details AS DD ON D.Doc_No = DD.Doc_No
 
But if you need it:
CREATE TABLE #tt (Doc_No INT, Material NVARCHAR(300), Quantity INT)
 
INSERT INTO #tt (Doc_No, Material, Quantity)
SELECT D.Doc_No, DD.Material, DD.Quantity
FROM Document AS D
    LEFT JOIN Document_Details AS DD ON D.Doc_No = DD.Doc_No
 
SELECT *
FROM #tt
 
DROP TABLE #tt
  Permalink  
v2
Comments
Sandeep Mewara at 29-Sep-12 9:54am
   
Will this do what OP asks?
"Now,my question is to inser Parent Grid Doc_No into my temparory DataTable"
 
I guess, your query simply selects and is not inserting anything in temptable.
Maciej Los at 29-Sep-12 10:05am
   
You are right, my query is a simply select instruction, because i'm not sure that OP realy need temporary table. ;)
Do you suggest me to correct my answer (rhetorical question, because i've change it now)?
Thanks Sandeep ;)
Sandeep Mewara at 29-Sep-12 10:47am
   
It's ok. I see you already updated it.
 
My 5 for the answer.
Maciej Los at 29-Sep-12 10:49am
   
Thank you, Sandeep ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100