How to do a loop to insert string to db in everyrows(Window Application)

Dear users, pls help me with this

How to do a loop that enable the user to insert every single string in every rows for the subsequently rows to insert into DB..

Dim icount As Integer = Me.DataGridView1.Rows.Count

For icount = 0 To icount
Dim s As String = Me.DataGridView1.Rows(0).Cells(0).Value
Dim s1 As String = Me.DataGridView1.Rows(0).Cells(1).Value
Dim s2 As String = Me.DataGridView1.Rows(0).Cells(2).Value
Dim s3 As String = Me.DataGridView1.Rows(0).Cells(3).Value
Dim s4 As String = Me.DataGridView1.Rows(0).Cells(4).Value
Dim s5 As String = Me.DataGridView1.Rows(0).Cells(5).Value
Dim s6 As String = Me.DataGridView1.Rows(0).Cells(6).Value
Dim s7 As String = Me.DataGridView1.Rows(0).Cells(7).Value
Dim s8 As String = Me.DataGridView1.Rows(0).Cells(8).Value
Dim s9 As String = Me.DataGridView1.Rows(0).Cells(9).Value
Dim s10 As String = Me.DataGridView1.Rows(0).Cells(10).Value
Dim s11 As String = Me.DataGridView1.Rows(0).Cells(11).Value

GraduatesTableAdapter.InsertQuery(s, s1, "Grad", s3, s4, s5, s6, s7, s8, s9, s10, s11)

Me._2006_Pupil_ProfileTableAdapter.DeleteQuery(s, s1)

Next



Answer this question

How to do a loop to insert string to db in everyrows(Window Application)

  • helseruwu

    do you need this

    Dim icount As Integer

    For icount = 0 To Me.DataGridView1.Rows.Count -1
    Dim s As String = Me.DataGridView1.Rows(icount).Cells(0).Value
    Dim s1 As String = Me.DataGridView1.Rows(icount).Cells(1).Value
    Dim s2 As String = Me.DataGridView1.Rows(icount).Cells(2).Value
    Dim s3 As String = Me.DataGridView1.Rows(icount).Cells(3).Value
    Dim s4 As String = Me.DataGridView1.Rows(icount).Cells(4).Value
    Dim s5 As String = Me.DataGridView1.Rows(icount).Cells(5).Value
    Dim s6 As String = Me.DataGridView1.Rows(icount).Cells(6).Value
    Dim s7 As String = Me.DataGridView1.Rows(icount).Cells(7).Value
    Dim s8 As String = Me.DataGridView1.Rows(icount).Cells(8).Value
    Dim s9 As String = Me.DataGridView1.Rows(icount).Cells(9).Value
    Dim s10 As String = Me.DataGridView1.Rows(icount).Cells(10).Value
    Dim s11 As String = Me.DataGridView1.Rows(icount).Cells(11).Value

    GraduatesTableAdapter.InsertQuery(s, s1, "Grad", s3, s4, s5, s6, s7, s8, s9, s10, s11)

    Me._2006_Pupil_ProfileTableAdapter.DeleteQuery(s, s1)

    Next



  • How to do a loop to insert string to db in everyrows(Window Application)