Problem with select on datatable

Posted on 2008-11-05
Last Modified: 2012-06-22

I have a problem with the select function on my datatable. A field on that tabel is called 'Quay', and I want to filter on it.
So, I enter the following code:

        lsFilter = "Quay = " + lsQuay
        filterResult = dtOrders.Select(lsFilter)

When I run this code, I get the error 'Cannot find column [QA01]'. My problem is: QA01 is the value in lsQuay, not the column.
Any Idea how I can solve this.

This code does work file:

        lsFilter = "[Location code] = " + lsLocation
        filterResult = dtOrders.Select(lsFilter)

I cannot see a difference between the 2 code snippets. I tried the filter "[Quay] = " + lsQuay, but that doesn't work either.

Kind regards
Question by:ACAE
    LVL 44

    Accepted Solution

    Hello ACAE,

    Location code is presumably numeric!

    What you need is this:

    lsFilter = "Quay = '" & lsQuay & "'"


    lsFilter = String.Format("Quay = '{0}'",lsQuay)


    lsFilter = String.Concat("Quay = '",lsQuay,"'")

    Which all provide the correct string but in different ways.



    Author Comment

    Damn, I feel kind of stupid now. Location is not a numeric fields, but the content is numeric.

    Thx for your help, it works fine now.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now