I thought i already assigned it?

string srch1 = "";
            string srch2 = "";

            if (cb1.SelectedItem.ToString() == "Book Title")
            {
                srch1 = "Book_Title";
            }
            else if (cb1.SelectedItem.ToString() == "Call Number")
            {
                srch1 = "Call_Number";
            }
            else if (cb1.SelectedItem.ToString() == "Accession_Number")
            {
                srch1 = "Accession_Number";
            }


            if (cb2.SelectedItem.ToString() == "Ascending Order")
            {
                srch2 = "ASC";
            }
            else
            {
                srch2 = "DESC";
            }

As you can see, I already assigned it. So why the error?

Recommended Answers

All 2 Replies

You've misinterpreted the error, which is actually a warning, not an error.

You've assigned the data to your variable, but you don't use that variable anywhere in your code to get the data back out of it.

So even though you have for example: srch2 = "DESC"; you don't use that value anywhere.

I see. There's another error but it's not related with this. I understand this now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.