My table contains 10 columns. I need to insert a list using c#.
I have stored the details of multiple members, for each count its has to insert the consecutive details in the same row.
if (members.Count >= 1)
{
foreach (Members myList in members)
{
Command.Parameters.Add("first", SqlDbType.VarChar).Value = myList.first;
Command.Parameters.Add("last", SqlDbType.VarChar).Value = myList.last;
Command.Parameters.Add("age", SqlDbType.VarChar).Value = myList.age;
}
}
Example : for count=1 the table looks like "fName1","lName1",21
for count=2 the table looks like "fName1","lName1",21,"fname2","lName2",21
please help on this.
count=2do you mean it should insert into col1...col6 and forcount=3it will be col1...col9? If that is true it's a bad design. Each member should be on separate rowsforeachloop portion. and based on that list give us how should the tabel will look like.