Cannot perform '=' operation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple App set up for testing. I read in a CSV file into a
DataTable. Then I cycle thru integers from 100,000 to 99,999,999 and use the
following to see if that number exists in my DataTable:

For counter = 100000 To 99999999
Dim found_CSV_User() As DataRow
Dim CSV_User As DataRow

Console.Write(counter)
found_CSV_User = CSV_Users_Table.Select("EmployeeID = " & counter)
For Each CSV_User In found_CSV_User
Console.Write(" -- " & CSV_User("mobile"))
Next
Console.Write(vbCrLf)

Next


Numbers 100,000 thru 107,102 work as expected and give me the Mobile number
in the DataTable. When the counter hits
107,103, I get a System.Data.EvaluateException stating "Cannot perform '='
operation on System.String and System.Int32." on the CSV_Users_Table.Select
line.

BTW, I am using VB.NET, VS2005. It works fine in VS2003. I'm trying to
upgrade
my app.

What is so special about 107,103 and how can I get around it?

Thanks All!!
 
Look at your data in your datatable for the employee with employee id
107103. The error is not in trying to test a value, but rather in
trying to assign it. You're getting some kind of casting exception, I'm
assuming from trying to convert the data from the mobile column to type
int, which probably works for all your other rows, but not in this one.
I'm sure if you compare the mobile number for employee 107103 vs
107102, the difference will be pretty obvious. If not, paste the
values, or at least roughly the same values back here.

Bruce Dunwiddie
http://www.csvreader.com
 
Hi,

Could you check what type the EmployeeID column is? It seems to be a string
type column. You can try to following:

ound_CSV_User = CSV_Users_Table.Select("EmployeeID = '" & counter & "'")

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thanks for the input. The little tick marks were the answer. I should learn
to use this forum more quickly instead of banging my head against the monitor
all day long.

BTW, 107103 was the last number in the CSV file. 107102 was not even in the
file. All other 476 entries in the CSV file worked fine. Go figure. They all
work now.

Thanks again!!
 
You're welcome!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top