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

  • SEARCH
  • Home
  • 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 6545451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:35:12+00:00 2026-05-25T11:35:12+00:00

I have Memberships and Bookings tables in a database containing an attribute cust_id, which

  • 0

I have Memberships and Bookings tables in a database containing an attribute cust_id, which is the primary key in Memberships and reference key in Bookings. When I am executing a data reader I want it to read cust_id values from membership table but it is reading it from the bookings table.

Also, when I compare two cust_id values, 1 taken from a textbox and the other taken a from database column, even though both are the same, but the comparison result is false. I have compared using string.equals(str1, str2) and have also compared the two directly using if statement. But in both cases, even if the string is the same, the result is otherwise.

My query is:

 str2 = "select Memberships.cust_id from Memberships, Bookings where   Memberships.cust_id = Bookings.cust_id"
Dim cmd2 As New SqlCommand(str2, con)
con.Open()

Dim bookchk As SqlDataReader = cmd2.ExecuteReader  
While bookchk.Read()
Dim str1 As String = MskdTxtCustId.Text
Dim str3 As String = bookchk("cust_id")
MessageBox.Show(str1 & "," & str3 & String.Equals(str1, str3))

End While
    bookchk.Close()
    con.Close()
  • 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-05-25T11:35:14+00:00Added an answer on May 25, 2026 at 11:35 am

    Try explicitly stating that you want an INNER JOIN instead:

    str2 = "select m.cust_id from Memberships AS M " &_
           " INNER JOIN Bookings AS B ON B.cust_id = M.cust_id;"
    

    When comparing, use String.Compare(), and make sure you’re trimming whitespace, just in case.

    Dim str1 As String = MskdTxtCustId.Text.Trim()
    Dim str3 As String = bookchk("cust_id").ToString().Trim()
    
    Dim compareResult As Integer = String.Compare(s1, s2)
    MessageBox.Show("compare str1: {0}, str3: {1}, result: {2}" , str1, str3, compareResult)
    
    compareResult = String.Compare(s1, s2, True)
    MessageBox.Show("Compare insensitive. result: {0}", compareResult)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Problem in datareader retrieving data I have Memberships and Bookings tables in
I have 3 tables: people, groups and memberships. Memberships is a join table between
I am creating a personnel database and have multiple tables relating to a user
I have two tables 'memberships' and 'email_list'. Each contains an email address field. Some
I have an ASP.NET site with membership tables in a Main_DB for the site.
I have a table memberships . I supply my user with a text box,
I want to construct a system which is responsible for updating my database columns.
I have a need to design a system to track users memberships to groups
So I have an embedded document that tracks group memberships. Each embedded document has
I have a Model which I am using to track permissions in a hierarchical

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.