title: How to loop through object and insert into SQL Server 2008
body: <p>I'm using <code>VB.NET</code> AND <code>SQL SERVER 2008</code></p>
  
  <p>I've  Array of object that I need to <code>INSERT</code> into <code>SQL SERVER 2008</code> this is the object <img src="https://i.stack.imgur.com/TpJMw.png" alt="enter image description here"> </p>
  
  <p>this object will be <code>Inserted</code> in to three tables : </p>
  
  <ul>
  <li><p>First table will have the report information : [ id ,reportName , description , style ] after inserting this information i'll use the <code>@@IDENTITY</code> of this <code>Row</code> as <code>FK</code> for the second Table </p></li>
  <li><p>SECOND table : [id , id_first_table, comment,complete,finished,name,started,outcome] </p></li>
  </ul>
  
  <p><strong>Question</strong> will come with the third table 
  How can i loop through the checklist <code>Element</code> and inserting it to the third table using the second table id till the end of element </p>
  
  <p>like :</p>
  
  <pre><code> [id , id_second_table, 101 ,820] 
   [id , id_second_table'sameid', 101,831]
  </code></pre>
  
  <p>Here is what i have tried  : </p>
  
  <pre><code> DECLARE @reportId INT , @fieldId INT  
  
   INSERT INTO    
   dbo.tblReport(strReportName,strReportDescription,strReportStyle,
   strScource,dtmCreated)
   VALUES ('caustic' , 'titration caustic', 'simple table' ,'user' ,  getdate()) 
   SELECT @reportId = @@IDENTITY
  
   INSERT INTO dbo.tblReportFields   
   (lngReports,strFieldName,bolComment,bolComplete,bolFinished,
   bolOutCome,bolStarted,bolUser)
   VALUES (@reportId ,'caustic titration' , 1,0,1,0,0,0)
   SELECT @fieldId = @@IDENTITY 
  
   --LOOP AND INSERT ALL THE checklist Element 
  
    INSERT INTO dbo.tblReportTask (lngReportFields,lngChecklist,lngTask)
    VALUES (@fieldId, 814 , 1443)
  </code></pre>
  
  <p>any ideas on the best way of doing this will be also considered </p>