[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

Inserting Multiple records via loop

I need to create several records at one time using both data from a text box and from a query.  I created a button with the code-behind shown below and it works fine for creating numbered records.  The problem I am having is passing a value from the "GetVersionItemNoOnly" adapters into the insert statement.  Right now, the insert statement only uses an integer that index with each loop.  It need to pull a value from the 1st column of the row corresponding to the loop.  I attached a picture with some sample data to hopefully explain better.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim i As Integer
        Dim AuditQuestionCount As New LebWebTableAdapters._6SActiveQuestionsTableAdapter

        For i = 1 To AuditQuestionCount.GetVersionItemNoOnly.Count
            Dim NewAuditResultLine As New LebWebTableAdapters._6SAuditResultsTblTableAdapter
            NewAuditResultLine.InsertAuditResultQuery(DropDownList1.Text, i, Calendar1.SelectedDate, ListBox1.Text + ", " + ListBox2.Text + " & " + ListBox3.Text)
        Next

End Sub

Open in new window

sampledata.gif
0
Cldela0
Asked:
Cldela0
  • 2
1 Solution
 
neeraj523Commented:
hello

Will suggest you to use sql insert statements for bulk insert.. If interested, can provide more details on this..
0
 
Cldela0Author Commented:
neeraj523,
I would be interested in how to do that.  Thanks
0
 
neeraj523Commented:
hello

look at below code

<%
do while rs.EOF
  sql = sql & "INSERT INTO TABLENAME VALUES('a','a');"
rs.MoveNext
Loop

con.Execute sql
%>

this example is based on classic ASP.

Let me know if you have further questions..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now