Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert record from c# datatable to a database
    primarykey
    data
    text
    <p>I have this datatable, actually a list of datatable <code>List&lt;DataTable&gt; lstDataSource</code>, now for each table in the list I know there are exactly 6 rows, (monday to saturday!), but there can be any number of columns (well from 6 to 14 that is, the number of hours an employee is working per day!) So I know the limits of both rows and columns in each datatable. My point is how do I use this list of datatable to update (rather insert) all these values in read database table <code>EmpWorkSchedule</code>. What I know is total rows inserted would be <code>lstDataSource.Count * 6</code> right? Also, for any column that doesn't have values, (some employee work 6 hrs, some 7 hrs etc... ) other columns in that rows would be just set to null. (They are defined as nullable in database). I hope I madeself clear. So, how can I do this?<br> Also, if there's anything unclear, please feel free to ask.</p> <p><strong>EDIT :</strong> I have this list of <code>DataTable</code> <code>List&lt;DataTable&gt; lstDataTable</code>, what I want is to insert all rows from each of these tables in the list, to a database table named <code>EmpWorkSchedule</code>, all the values in each row are sequential, that is first column corresponds to column 1 in database table, and so on, okay? But now all rows have values for all column, some have 6, some 7, some 8.. What I want is that for the columns, for which, there is no value in the datarow, should be left null in the database table, rest all values should be inserted.</p> <p>Also, using an adapted doesn't seems likely because its used with select, I am not selecting anything, I am inserting something.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload