am having 2 dataset. named as ds, ds1. dataset value contain value like this
dataset(values from excel sheet)
--------
no phone title
91 9942321400 MR
91 9865015695 MR
91 9677031515 MR
91 9994828285 MR
91 9688104229 MR
dataset1 contain value like this(values from mysql table)
-------------------------------
phone
9942321400
9865015695
9677031515
compare 2 datset. if dataset are not equal to datset1 phone , we have to write that dataset phone no in notepad.but am getting wrong result.
mycode
Dim i As Integer = 0
Do While (i <= ds1.Tables(0).Rows.Count - 1)
Dim phone As String = ds1.Tables(0).Rows(i).Item(1).ToString
Dim j As Integer = 0
Do While (j <= Ds.Tables(0).Rows.Count - 1)
Dim dumphone As String = Ds.Tables(0).Rows(j).Item(4).ToString
If (dumphone <> phone) Then
TextBox1.AppendText(a.ToString & "|" & b.ToString & "|" & c.ToString)
sw.WriteLine(TextBox1.Text)
TextBox1.Text = ""
End If
j = (j + 1)
'i = i + 1
Loop
i = (i + 1)
Loop
my result in notepad
|91|9942321400|MR
|91|9942321400|MR
|91|9942321400|MR
|91|9942321400|MR
|91|9865015695|MR
|91|9865015695|MR
|91|9865015695|MR
|91|9865015695|MR
|91|9677031515|MR
|91|9677031515|MR
|91|9677031515|MR
|91|9677031515|MR
but expected output in notepad like this
----------------------------------------
91|9994828285|MR
91|9688104229|MR
Your code is comparing each line of the second dataset vs each line in the first.
Your Do While blocks go through the entire thing, there is no exclusion code for it.
So in your example, the first number it compares is dumphone(0) = 9942321400 It matches the first time it goes through the Do While when phone(0) = 9942321400. But then your Do While is still going. When it hits the second number, dumphone(1) = 9865015695, it doesn’t match, so you get your output line.
Here’s one option of how you could get the desired output