Rowfilter error: Cannot perform '=' operation on System.Int32 and System.String

M

marti

Probably a simple explaination for this, but I can't find it anywhere.
Using asp.net 2003 on windows xp.
I have a dataview with e-mail addresses and individual numbers. The
individual numbers (field IndividualNum) are in the form of
year-7DigitHex (05-0000023).
The following code line generates the above error:
dv.RowFilter = "IndividualNum = '05-0000023'"

As does this:
Dim tmpStr as String
tmpStr = "IndividualNum = '05-0000023'"
dv.RowFilter = tmpStr

It does work with other filters, such as:
dv.RowFilter = "IndividualNum = '7097'"
dv.RowFilter = "IndividualNum = 'Frank'"

It seems like the dash is telling it to subtract 0000023 from 05,
eventhough it's enclosed in single quotes. Is this what the problem is?
If so, is there a way around it? Thanks!
-Jeff
 
R

Rogas69

yes it is strange :)
try tmpStr = "IndividualNum = '05' + '-0000023'"
or something similar

peter
 
M

marti

Thanks for the quick response, but good try. It seems as long as there
is a dash anywhere in the field value, it will try to subtract it. I've
even went as far as trying:
tmpStr = "IndividualNum = '" + "A05A" + "A-00023A'"
dv.RowFilter = CStr(tmpStr.ToString())
When is a string a string?
 
G

Guest

Marti,
What is the data type of the field IndividualNum?
The error message leads me to believe that ADO is complaining about being
asked to compare a field of type Int32 to a string.

Double check to be sure that the field in the dataview is indeed a string.

Dave
 
J

jeff martin

You the man! Led me right to it... The type had been changed in the
database, but I had to re-do the dataset schema to reflect that it was
now a string. Thanks much you guys!
-Jeff
 
D

dale mitchell

i've gotten the same error with the same circumstances ("-" in a string
field--i checked and field is a char field in the sql table, so i still
can't figure out what the problem is or how to fix it.

a second problem i have is how to pass a variable to the rowfilter--i can
hard code the date in as below and it works

DataViewProposals.RowFilter = "Project_start>'7/1/2004'"

but if i try to pass a variable to it, no luck. can anyone help me with the
syntax?

thanks
dale
 
M

Mark Ashton

You can't pass variables to the RowFilter property by reference, only by
value as part of the string expression itself. Just track when your
variable changes and the update the RowFilter expression at the same time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top