Asked by:
ARRGH! Duplicating data display (sometimes)

Question
-
User-1247952564 posted
I have an application built by someone else that is returning results from a socket call when the end user types in a little product info, and hits submit. The application returns the results, but it sometimes displays the results twice. For example, if I click submit on the application to do a search for a product, it may come back with the correct one, two, or three records (as there could be results from 1-3 locations), or it may repeat all those results twice. (Ie.: if there were two records returned, it might simply display the info from the two records, or it may display the results from the two records in the first two rows of the , and then repeat rows 1 & 2 in rows 3 & 4.) Continuing to click submit on that page will (it appears randomly) change the resulting displayed data - cycling between one set of results and two.
I've included the bit of code I think is involved. I inherited this code, and am trying to make it work, but I'm new to this type of application and only intermediate at best in asp.net. Thank-you in advance to anyone who can shed some light!!
I hope this is clear enough..
Protected Sub displayTableOne(ByVal records() As String) Dim dt As New DataTable() Dim values() As String = {""} Dim i As Integer = 0 Try Dim Row() As String = {"Company", "Piece", "Description", _ "Location", "Available", "Purchased", "Ship Date"} 'Create the columns Dim column1 As New DataColumn("Company", GetType(String)) Dim column2 As New DataColumn("Piece", GetType(String)) Dim column3 As New DataColumn("Description", GetType(String)) Dim column4 As New DataColumn("Location", GetType(String)) Dim column5 As New DataColumn("Available", GetType(String)) Dim column6 As New DataColumn("Purchased", GetType(String)) Dim column7 As New DataColumn("Ship Date", GetType(String)) dt.Columns.Add(column1) dt.Columns.Add(column2) dt.Columns.Add(column3) dt.Columns.Add(column4) dt.Columns.Add(column5) dt.Columns.Add(column6) dt.Columns.Add(column7) If (records.Length > 1) Then For i = 0 To records.Length - 2 Step 1 values = Split(records(i), "|") Dim l As Integer = 0 Dim dr As DataRow dr = dt.NewRow() If values(0) = "05" Then If (values.Length > 4) Then dr(Row(0)) = values(1) dr(Row(1)) = values(2) dr(Row(2)) = values(13) dr(Row(3)) = values(17) dr(Row(4)) = values(7) dr(Row(5)) = values(15) dr(Row(6)) = values(16) End If dt.Rows.Add(dr) End If Next If values(23) = "Error" Then invalidMessage() Else 'Bind the DataTable to the DataGrid Table1.Visible = True Table1.DataSource = dt Table1.DataBind() End If End If Catch ex As Exception invalidMessage() Finally Array.Clear(records, 0, records.Length) Array.Clear(values, 0, values.Length) End Try End Sub
If I run this on localhost, their is no duplication of data, but on the site there is. Does that help to give people an idea of what may be going on?Tuesday, October 11, 2011 2:40 PM
All replies
-
User42903263 posted
I think you need to check what is in your array records, then perhaps examine how it was generated if there are actually duplicate records in that.
--
AndrewWednesday, October 12, 2011 1:51 PM -
User-1247952564 posted
HI Andrew,
Thanks for looking at this. I've checked though, and the data is "coming in" the same way each time, but it gets mangled once it's in the application.
Thursday, October 13, 2011 8:57 AM -
User-1247952564 posted
On review, I see that the data is being called once - but it looks like it is being duplicated by times once assigned to "records" - looking at this more now...
Thursday, October 13, 2011 11:15 AM