Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27124

VS 2008 InvalidArgument = Value of "4" is not valid for 'index' Parameter name: index

$
0
0
Im getting the error
"InvalidArgument = Value of "4" is not valid for 'index' Parameter name: index" (that should be 'year_purchased' field)
while adding items from Listview to sql database...

the same error occurs when im trying to generate a csv file from listview items.. the error also occurs on the field of 'year_purchased'


Code:

Try
            Dim LvItem As ListViewItem
            icount = ListView2.Items.Count
            If Not ListView2.Items.Count = 0 Then
                Do Until iloop = ListView1.Items.Count
                    LvItem = ListView2.Items.Item(iloop)
                    With LvItem
                        cmd = New SqlCommand("INSERT INTO 'TABLE'(entity, class,_______, year_purchased, group_code, __________, package_series, quantity_series, assetid, asset_name,___________, hostname, brandmodel, serialnumber, userr, supplier, years_of_warranty_left, __________, location, deployment_pullout_date, asset_last_inventory_date, scanningstatus, new_location,___________, disposition, asset_condition, condition, date_asset_last_used) Values('" _
                                        & .SubItems(0).Text & "','" _
                                        & .SubItems(1).Text & "','" _
                                        & .SubItems(2).Text & "','" _
                                        & .SubItems(3).Text & "','" _
                                        & .SubItems(4).Text & "','" _
                                        & .SubItems(5).Text & "','" _
                                        & .SubItems(6).Text & "','" _
                                        & .SubItems(7).Text & "','" _
                                        & .SubItems(8).Text & "','" _
                                        & .SubItems(9).Text & "','" _
                                        & .SubItems(10).Text & "','" _
                                        & .SubItems(11).Text & "','" _
                                        & .SubItems(12).Text & "','" _
                                        & .SubItems(13).Text & "','" _
                                        & .SubItems(14).Text & "','" _
                                        & .SubItems(15).Text & "','" _
                                        & .SubItems(16).Text & "','" _
                                        & .SubItems(17).Text & "','" _
                                        & .SubItems(18).Text & "','" _
                                        & .SubItems(19).Text & "','" _
                                        & .SubItems(20).Text & "','" _
                                        & .SubItems(21).Text & "','" _
                                        & .SubItems(22).Text & "','" _
                                        & .SubItems(23).Text & "','" _
                                        & .SubItems(24).Text & "','" _
                                        & .SubItems(25).Text & "','" _
                                        & .SubItems(26).Text & "','" _
                                        & .SubItems(27).Text & "')", con)
                        cmd.ExecuteNonQuery()
                    End With
                    iloop = iloop + 1
                    LvItem = Nothing
                Loop
                MsgBox("Server Database Updated")
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        cmd.Dispose()
        con.Close()

Thanks everyone!

Viewing all articles
Browse latest Browse all 27124

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>