[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with select on datatable

Posted on 2008-11-05
2
Medium Priority
?
1,332 Views
Last Modified: 2012-06-22
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
0
Comment
Question by:ACAE
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 22885508
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
 

Author Comment

by:ACAE
ID: 22885547
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 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