Solved

dataset problem

Posted on 2006-11-26
4
243 Views
Last Modified: 2010-04-23
I have the following code :
what I am trying to do is test if two fields equal each other, then remove them from the dataset. The dataset has t_security default value set to 0 and will not allow nulls....

the string filter seems to be the problem

sqlStatement = " select masterid,cust_lastname,cust_signup,cust_security," & _
        "t_security,(cust_security-t_security) as xResult from master " & _
        "left outer join tblTerminate " & _
        "on masterid = bridge  "

        adaptVdb1 = New VistaDBDataAdapter(sqlStatement, conn)
        Mysecurity = New DataSet

        adaptVdb1.Fill(Mysecurity, "Master")

        Dim oTempTable As DataTable = Mysecurity.Tables("Master")
        Dim foundRows() As DataRow
        Dim getRow As DataRow
        Dim strFilter As String = "cust_security=0" <------------------works, it "cust_security = t_security", doesnt work, returns all records
        foundRows = oTempTable.Select(strFilter)

        For Each getRow In foundRows
            oTempTable.Rows.Remove(getRow)
        Next

        Mysecurity.AcceptChanges()

0
Comment
Question by:stephenz43
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 18015338
Ok, so when cust_security=0 its ok ?

Don't quite understand whats working and what isn't ?
0
 

Author Comment

by:stephenz43
ID: 18015364
when strFilter = Cust_security = 0...i get only records where cust_security = 0

what I want to accomplish is if cust_security = t_security as the filter....... doesnt want to work
0
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
ID: 18015707
In so far as I understand your sqlStatement (a) it looks like the filter should work but (b) so should xResult = 0.  That is because if cust_security = t_security then (cust_security-t_security) = 0.  So that might be an alternative to try.

If that fails as well then I think you want to stick in some debug code to test for the values in cust_security and t_security, as it looks like they might be other than expected.

Roger
0
 
LVL 39

Assisted Solution

by:appari
appari earned 250 total points
ID: 18016233
are you getting some error or its returning 0 records?
if returning 0 records try the following filter,
Dim strFilter As String = "cust_security <> t_security"

check the count of records selected and see if it is same as base tables record count. if same means
cust_security and t_security are not equal for all the records.

in case you are getting error post the error message here
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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