Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:11:09+00:00 2026-06-09T21:11:09+00:00

I’m using VB.NET AND SQL SERVER 2008 I’ve Array of object that I need

  • 0

I’m using VB.NET AND SQL SERVER 2008

I’ve Array of object that I need to INSERT into SQL SERVER 2008 this is the object enter image description here

this object will be Inserted in to three tables :

  • First table will have the report information : [ id ,reportName , description , style ] after inserting this information i’ll use the @@IDENTITY of this Row as FK for the second Table

  • SECOND table : [id , id_first_table, comment,complete,finished,name,started,outcome]

Question will come with the third table
How can i loop through the checklist Element and inserting it to the third table using the second table id till the end of element

like :

 [id , id_second_table, 101 ,820] 
 [id , id_second_table'sameid', 101,831]

Here is what i have tried :

 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)

any ideas on the best way of doing this will be also considered

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:11:11+00:00Added an answer on June 9, 2026 at 9:11 pm

    Okay, your info was a little hard to work with since your Object and SQL Statements don’t quite match up. However, here is basically how you do it. I hope you can relate it back to your problem.

    This is how you insert the Report and ReportFields tables. I didn’t include the SQL for the ReportFields table since it is similar to the Report one.

      Dim reportID As Integer = 0
      Dim fieldID As Integer = 0
      Using tmpCONN As New SqlConnection(tmpConnStr)
        Dim tmpSQL As New StringBuilder
        tmpSQL.AppendLine("INSERT INTO dbo.tblReport(strReportName,strReportDescription,strReportStyle,strScource,dtmCreated) ")
        tmpSQL.AppendLine(" VALUES ")
        tmpSQL.AppendLine("(@NAME, @DESC, @STYLE, @SOURCE,@CREATED); ")
        tmpSQL.AppendLine("SELECT SCOPE_IDENTITY() AS ScopeID; ")
        Using tmpCMD As New SqlCommand(tmpSQL.ToString, tmpCONN)
          tmpCMD.Parameters.AddWithValue("@NAME", Obj.Name)
          tmpCMD.Parameters.AddWithValue("@DESC", Obj.Description)
          tmpCMD.Parameters.AddWithValue("@STYLE", Obj.Stype)
          tmpCMD.Parameters.AddWithValue("@SOURCE", Obj.Source)
          tmpCMD.Parameters.AddWithValue("@CREATED", Date.Now)
          reportID = tmpCMD.ExecuteScalar
        End Using
    
        'Do same type of insert here for the ReportFields table.  Instead of reportID,'
        'it would return fieldID.'
    
    
        'This is the loop to insert to Tasks'
        For Each chk As chkObj In Obj.Checklist
          tmpSQL = New StringBuilder
          tmpSQL.AppendLine("INSERT INTO dbo.tblReportTask (lngReportFields,lngChecklist,lngTask) ")
          tmpSQL.AppendLine(" VALUES ")
          tmpSQL.AppendLine("(@FIELD_ID, @CHECK_ID , @TASK) ")
          Using tmpCMD As New SqlCommand(tmpSQL.ToString, tmpCONN)
            tmpCMD.Parameters.AddWithValue("@FIELD_ID", fieldID)
            tmpCMD.Parameters.AddWithValue("@FIELD_ID", chk.cl_id)
            tmpCMD.Parameters.AddWithValue("@FIELD_ID", chk.ts_id)
            tmpCMD.ExecuteNonQuery()
          End Using
        Next
      End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I know there's a lot of other questions out there that deal with this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.