Problem with table.select(criteria)

From: moondaddy (moondaddy_at_nospam.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 00:11:35 -0500

I'm trying to filter a table using the select method like this:

Note: dsSessionMngr is a strongly typed dataset
         CustRef is a string column in the dataset's table named CartDetails

Dim tb As dsSessionMngr.CartDetailsDataTable = Me.dsSM.Tables("CartDetails")
Dim crit as string = "1234 - Blue" '1234 is not a number but is just part
of a alphanumeric value
Dim foundRows() As dsSessionMngr.CartDetailsRow = tb.Select("CustRef = " &
crit )

When this 3rd line executes I get an exception saying:
Cannot find column [Blue].

It thinks I'm taking a numeric value of 1234 and subtracting the value in a
column called 'Blue'. So I tried wrapping the criteria in single quotes and
double quotes similar to what you might do in sql server for a varchar
parameter variable. the double quote bombed with some sort of syntax error,
but single quote gave me an exception saying:
You can not use "=" when comparing datatypes string and int32.

This is because the value in the dataset was a string value of "1234" and
the criteria was " '1234 - Blue' ".

ADO is trying to be too smart and figure things out for itself. The column
is a string data type and I'm comparing it with a string value for the
criteria which is what I'm supposed to do.

How can I get this to work?

Thanks.

-- 
moondaddy@nospam.com


Relevant Pages

  • Re: Mandis Quotes (aka retiring """ and )
    ... > surround the string by a pair of doubled single quotes. ... > an arbitrary string in-between the single quotes which does NOT ... > of ASCII or Unicode characters, but instead as a sequence of lines ...
    (comp.lang.python)
  • Re: quotes from form input + MySQL insert query
    ... string mysql_escape_string ... > same way, but a textarea string full of single quotes is handled fine, while ... I've checked the POSTed data by echoing ... > backslashes, in case the single ones generated by magic_quotes weren't ...
    (alt.php)
  • Re: Mandis Quotes (aka retiring """ and )
    ... >surround the string by a pair of doubled single quotes. ... > of ASCII or Unicode characters, but instead as a sequence of lines ... Quoting "arbitrary" text also involves the issue of encoding, ...
    (comp.lang.python)
  • RE: Trouble with SQL String in VBA
    ... It looks like the problem is with the string delimiters. ... *You have single quotes within single quotes. ... Dim rst As DAO.Recordset ... 'default bln to FALSE ...
    (microsoft.public.access.modulesdaovba)
  • Re: Strongly Typed Datasets accessing query using IN
    ... To make an XSD you can use a resultset from a table or an other SP, however the SP itself is not in the strongly typed dataset itself. ... SELECT WHERE IN (<the string>) statement, ... SQL command that doesn’t return rows. ...
    (microsoft.public.dotnet.framework.adonet)