Problem with select on datatable

Hello,

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
ACAEAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hello ACAE,

Location code is presumably numeric!

What you need is this:

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

Or

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

Or

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

Which all provide the correct string but in different ways.

Regards,

TimCottee
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ACAEAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.