Hello
kindly help me to solve my problem to check item listview to avoid duplicate item in database.
I have 1 listview, my plan the listview checking each item from database before insert to database.
and item in listview obtained from opendialog excel
this is my code :
when items duplicate already exist, my app error/stop at cmd.ExecuteNonQuery()
and I'm hopeless to code check each item when reportcode exist in row of 5 or other row
Private Sub BBIUpload_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBIUpload.ItemClick
Dim iCount As Integer
Dim iLoop As Integer
Dim cmd As New MySqlCommand
Dim lvitem
cmd.Connection = New MySqlConnection("server=localhost; user id=root; password=mypass; database=custdata")
cmd.Connection.Open()
iCount = lvlistpocorr.Items.Count
'For iLoop = 0 To lvLogs.Items.Count - 1
If Not lvlistpocorr.Items.Count = 0 Then
Do Until iLoop = lvlistpocorr.Items.Count
lvitem = lvlistpocorr.Items.Item(iLoop)
With lvitem
cmd.CommandText = "insert into cust_reportcode(reportcode,first_name,last_name,total_item,total_price,date_trasaction) values " _
& "('" & lvitem.subitems(0).text & "','" & lvitem.subitems(1).text & "','" & lvitem.subitems(2).Text & "','" & lvitem.subitems(3).Text & "','" & lvitem.subitems(4).Text & "','" & lvitem.subitems(5).Text & "')"
cmd.ExecuteNonQuery()
End With
iLoop = iLoop + 1
lvitem = Nothing
Loop
Else
MsgBox("Duplicate ID Report Code", MsgBoxStyle.Information, "Information")
End If
ExportXml()
MsgBox("done")
End Sub
If any one knows the solution please let me know.
Thanks in advance.