Solved

dataset problem

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now