I would recommend that you use the new Multirow insert statement in SQL 2008 so that you can simply pass the sql statement as follows:
INSERT INTO table1(id,animal_name) values (1,cat),(1,dog),(1,horse)...
In your SqlCommand, but I donβt know how to build such a statement without the risk of becoming a victim of a SQL Injection attack.
Another alternative is to determine the types of data tables in your sql database: 

And then build a DataTable in C # that matches the definition of your data type:
DataTable t = new DataTable(); t.Columns.Add("id"); t.Columns.Add("animal_name"); foreach(var element in your animals_list) { DaraRow r = t.NewRow(); r.ItemArray = new object[] { element.id, element.animal_name }; t.Rows.Add(r); }
More details here .
Or, if you are familiar with stored procedures, like the previous sentence, but having a stored procedure, get the DataTable t parameter as the parameter.
If none of the above actions work for you, create an SqlTranscation from the Connection object and iterate through each row of each data set, insert the record in the corresponding table, and finally complete the transaction. An example is here.
source share