Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
how i can insert multiple rows in a table using loop,
i want to design like this
day sub1 sub2
mon hindi eng
tues eng math
thu math history
Posted 14-Jan-13 23:08pm
Edited 14-Jan-13 23:24pm
v2
Comments
Zoltán Zörgő at 15-Jan-13 5:20am
   
It depends.
Zoltán Zörgő at 15-Jan-13 5:26am
   
And what have you tried so far? What is the concrete technical problem, error message you are facing?
HYD Webdeveloper at 15-Jan-13 5:32am
   
try this !
 
Insert into TABLENAME (Day,Sub1,Sub2)
Select 'mon','Hindi','Eng'
union all
Select 'Tues','Eng','Math'
union all
Select 'wed','Hindi','Science'
union all
Select 'Thu','Math','history'
union all
 
This will help you.

1 solution

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

Solution 1

That is going to depend on a heck of a lot of factors, like "where is your information coming from?" and "where is the table data going to go?" but the basic table is pretty easy:
            DataTable dt = new DataTable();
            dt.Columns.Add("day");
            dt.Columns.Add("sub1");
            dt.Columns.Add("sub2");
            dt.Rows.Add("mon", "hindi", "eng");
            dt.Rows.Add("tues", "eng", "math");
            dt.Rows.Add("thu", "math", "history");
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 448
1 Sergey Alexandrovich Kryukov 290
2 PhilLenoir 95
3 Uma Shankar Patel 80
4 CB Sharma 79
0 Sergey Alexandrovich Kryukov 6,532
1 OriginalGriff 5,976
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,550


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 15 Jan 2013
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