473,473 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Rows.contains sometimes return false even though the value is there

5 New Member
Hi,
I'm using the following method to find the itemcode in a table.

Expand|Select|Wrap|Line Numbers
  1. dim ds as new dataset
  2. dim mvItem as object
  3.  
  4. Dim tmpCol(1) As DataColumn
  5. tmpCol(0) = dsPDT.Tables(0).Columns(0)
  6. dsPDT.Tables(0).PrimaryKey = tmpCol
  7.  
  8. mvItem = dsBoss.Tables(0).Rows(i)(0).ToString
  9. If dsPDT.Tables(0).Rows.Contains(mvItem) = False Then
  10.      do something
  11. else
  12.      do something
  13. endif
  14.  
  15. ITEM_CODE                                 NOT NULL VARCHAR2(13)
  16. ITEM_SCAN_CODE                                     VARCHAR2(20)
  17. ITEM_SUPL_CODE                                     VARCHAR2(5)
Here ITEM_CODE is the primary key and ITEM_CODE contains 9 digits and 13 digit.

Sometime the contains retunring false even though the Item is ther in the dataset.

Could anyone help me please to solve this issue ?
Aug 25 '08 #1
3 3087
Plater
7,872 Recognized Expert Expert
.contains comapres objects types, not just a human readable value.
If your string value is "3456" because the column it looked at was an integer column with that value, doing a .contains on an integer column with a string representation will fail.
You have declared mvItem as an object, but are always assigning it to be a string with that ToString call, I think getting rid of that will help solve your problem?
Aug 25 '08 #2
abutaher
5 New Member
.contains comapres objects types, not just a human readable value.
If your string value is "3456" because the column it looked at was an integer column with that value, doing a .contains on an integer column with a string representation will fail.
You have declared mvItem as an object, but are always assigning it to be a string with that ToString call, I think getting rid of that will help solve your problem?
Dear,
I've removed ToString from the following line but still it is returning false.
Expand|Select|Wrap|Line Numbers
  1.  mvItem = dsBoss.Tables(0).Rows(i)(0).ToString 
ITEM_CODE I've declared as string but it contains numeric value only(i.e. 100045020 )
Aug 26 '08 #3
Plater
7,872 Recognized Expert Expert
Does it EVER return true? Its looking for the primary key which you just declared which column was the primary key?

Have you tried setting a break point and stepping through the code, to see what it is being compared to?
Aug 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jim Hatfield | last post by:
I'm using: "select min(objid) from table_name where objid > $objid" to select the next row in a sequence where there may be gaps. It works fine unless the where clause results in an empty set. ...
2
by: serge calderara | last post by:
Dear all, I am populating a treeview control with an XML file. I need to skip duplicate node entry from XML file in treeview if exit For that I ma using the following line of code : If...
3
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
11
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
3
by: vunet.us | last post by:
To highlight the table's row with onmouseover/onmouseout events I use 2 functions which switch rows' class names. How can I highlight the same rows, if every cell of the row contains various class...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.