Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 14-Jan-13 23:24pm
v2
Comments
Zoltán Zörgő 15-Jan-13 5:20am    
It depends.
Zoltán Zörgő 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 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

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:
C#
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");
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900