Hi, I'm trying to upload inventory data from .csv file (10 columns). Some users are complaining that records are uploaded without complete data update. But, when I ask them to re-upload after deleting the records, no issue found. I am now doubtful where things are going wrong, either my program or their steps or some other issue like network etc. Or, my program fails due to more than one upload at a time. Below is my program process, pls help.
Code:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
''''''convert csv to datatable''''''''''''
Call CSVtoDataTable(Me.txtUploadFile.Text)
Me.dgCsvUpload.DataSource = (dt)
''''''validate datatable''''''''''''''''''''''''
If (dt Is Nothing) Or (dt.Rows.Count = 0) Then
MsgBox("Empty datatable! No record to upload.", MsgBoxStyle.Exclamation)
dt.Clear()
Exit Sub
Else
''''''verify column header(s)''''''''''''''''
If UCase(dt.Columns(0).ColumnName) <> ("TAG_NO") Then
'MsgBox(dt.Columns(0).ColumnName)
MsgBox("Incorrect column header for column " & dt.Columns(0).ColumnName, MsgBoxStyle.Exclamation)
dt.Clear()
Exit Sub
''
''
Else
''''''validate datagrid records''''''''''
dt_err.Columns.Add("Error Definition", GetType(String))
Dim i2 As Integer
For i2 = 0 To Me.dgCsvUpload.Rows.Count - 1
If String.IsNullOrEmpty(Me.dgCsvUpload.Item(0, i2).Value) Then
dt_err.Rows.Add("Empty cell found at " & "(" & Me.dgCsvUpload.Item(0, i2).ColumnIndex & _
"," & Me.dgCsvUpload.Item(0, i2).RowIndex & ")")
Else
Dim sqlstr As String
sqlstr = "Select * From inventory_details where tag_no = '" & Me.dgCsvUpload.Item(0, i2).Value & "'"
If DataGridRecordExist(sqlstr) = True Then
dt_err.Rows.Add("Duplicate tag number found at " & "(" & Me.dgCsvUpload.Item(0, i2).ColumnIndex & _
"," & Me.dgCsvUpload.Item(0, i2).RowIndex & ")")
Else
''
''
End If
End If
''''''clear temp table'''''''''''''''''''
Call ConnectDB()
conndb.Execute("Delete From inventory_temp")
conndb.Close()
''''''upload data to temp table''''''''''''''''
Call UploadToTempTbl()
''''''''update temp table'''''''''''''''''''''''''
Call UpdateTempTbl()
''''''transfer uploaded data to permanent table'''''''
Call UploadToPermTbl()
MsgBox("Data transfered successfully!", MsgBoxStyle.Information)
Me.Cursor = Cursors.Default
Me.txtUploadFile.Text = ""
End Sub