Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:07:56+00:00 2026-06-08T02:07:56+00:00

am having 2 dataset. named as ds, ds1. dataset value contain value like this

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:07:57+00:00Added an answer on June 8, 2026 at 2:07 am

    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

    Dim toggle as Boolean = false
    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 toggle = true 'This will set your flag to add the output.
                j = (j + 1)
            Loop
                'After we're done checking if there's a match, we decided to add it to the output.
                If toggle = true Then
                    TextBox1.AppendText(a.ToString & "|" & b.ToString & "|" & c.ToString)
                    sw.WriteLine(TextBox1.Text)
                    TextBox1.Text = ""
                    toggle = false 'Reset the flag for the next value
                End If
                i = (i + 1) 'Move to the next value to check against.
        Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues trying to retrieve unique values from a DataSet in csharp,
I m having function which export data of dataset to an excel sheet. it
I have a DataSet populated from Excel Sheet. I wanted to use SQLBulk Copy
I am having trouble updating my Database from my code using a DataSet. I'm
I'm having issues trying to deserializing my xml string that was from a dataset..
I have been having this problem for quite some time. I create a dataset
Hello I'm having a problem here. The code looks like this. private void Form3_Load(object
Hi I'm having trouble extracting data from this XML document. <messages messageCount=6> <message messageID=9999
We are currently having a discussion if dataset should go in the data or
Given this sample dataset: item ---- item_id item_name item_added 1 Apple <date_time> 2 Banana

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.