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 6858997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:13:45+00:00 2026-05-27T02:13:45+00:00

I am trying to pull information for items to display on the page. For

  • 0

I am trying to pull information for items to display on the page. For some reason, the Master Category (masCat.cat_name) is not returning data. Here is the code for my SQL statement:

  strSQL.CommandText = "Select Top 25 tblItem.item_id, tblItem.item_title
     , masCat.cat_name, regCat.cat_name, tblItem.item_lot, tblCosigner.cs_txt_id
     , tblItem.item_status, tblItem.item_photo_status, tblItem.item_pr
     , tblItem.item_premium
  From tblItem
  Left Join tblCosigner On (tblItem.item_cs_txt_id = tblCosigner.cs_txt_id)
  Left Join tblCDR On (tblItem.item_cdr_txt_id = tblCDR.cs_id)
  Left Join tblCat As masCat On (tblItem.item_mcat_id = masCat.cat_id)
  Left Join tblCat As regCat On (tblItem.item_cat_id = regCat.cat_id)
  Where " + sqlQuery + "
  Order By tblItem.item_id;";
  try
  {
      conn.Open();
      using (SqlDataReader itemReader = strSQL.ExecuteReader())
      {
          while (itemReader.Read())
          {
              resultText += "<tr>\n<td>" + itemReader.GetValue(0).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(1).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(2).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(3).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(4).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(5).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(6).ToString() + "</td>\n";
              resultText += "<td>" + itemReader.GetValue(7).ToString() + "</td>\n";
              if (itemReader.GetValue(8).ToString().Length > 0)
              {
                  price = double.Parse(itemReader.GetValue(8).ToString());
              }
              if (itemReader.GetValue(9).ToString().Length > 0)
              {
                  premium = double.Parse(itemReader.GetValue(9).ToString());
              }
              total = price + premium;
              resultText += "<td>" + total.ToString("0.00") + "</td>\n</tr>\n";
          }
          itemReader.Close();
      }
  }

I was thinking that my join statement was incorrect for the masCat join, but if I just change tblItem.item_mcat_id to just tblItem.item_cat_id (which is the secondary category, also selected in this same query), it works just fine. Both are being pulled from the exact same table, but by different associated fields in the relational table. I am positive tblItem.item_mcat_id is the correct name of the field for the master category id.

Now I am used to using MySQL, and I do know that with SQL you are supposed to do a Group By as well. But I do not know what I would group by other than tblItem.item_id so that it does not combine rows of data. So I don’t see how that would solve my issue either. Can anyone see anything wrong with this SQL statement? Everything returns fine except for the master category.

I got interrupted several times while writing this, so I kind of lost track of my thinking during it, so I hope I gave enough information. If not, just ask, and I will respond or update my question. Thanks in advance…

EDIT

It’s in the comments, but the sqlQuery variable has a default value of “tblItem.item_id > 0”. It works if I add other criteria to it dynamically (not including the master category still).

Also, I must not have stated something right, but I do receive results from this. I am only missing the master category field (it’s returning blank for this one). The query itself is not failing.

FIXED

Whoever created the tables originally made the tblItem.item_mcat_id zero pad… -.-

  • 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-27T02:13:46+00:00Added an answer on May 27, 2026 at 2:13 am

    Based on the description you’ve given, I’d have to say that these two columns:

    tblItem.item_mcat_id = masCat.cat_id
    

    Are not the same type or one contains padding where the other does not. You might have to do a cast. Finally MAKE SURE that the item.mcat_id DOES ACTUALLY exist in the cat_id column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pull some information (no recursion necessary) from a jsp page (malformed
Hello I am trying to pull information from a page on Wikia for The
I'm trying to pull id, gender, birthday, username, friends list and some other information
I am trying to pull up some data. Here is the setup: A [school]
Accomplished pulling data from JSON, but having problems trying to pull additional information from
Trying to pull information from a web page for use in a Android app.
I am trying to pull a page for parsing information out of it using
I am trying to pull information from another site. When I try and do
There is a website I am trying to pull information from in Perl, however
How can I pull relevant packet information from a JpCap packet? I am trying

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.