Solved

dataset problem

Posted on 2006-11-26
4
241 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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