can I compare one record from one table to another record in another table?

can I compare one record from one table to another record in another table? I need to test if this condition is met. My scenario is:

i need to check one table for a value and compare it to a list of records. for example,

table 1
           column
record 1- apples
record 2- oranges
record 3- grapes

table 2
            col1   col2   col3    col4
record 1- Null , Null, Null, grapes

I need to compare table 2 records with a list of records from table 1.
the fruit can be in any of the 5 columns because the user will have a submit button that submits this data in teh databse at any of the 5 columns.

Is there a way to retrieve a record from the 4 columns and compare to the list of records in another table?? I need to check if a value exists in either one of the columns that match a value in another table.

0
cluce
7/13/2008 10:14:29 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
957 Views

Similar Articles

[PageSpeed] 9

I starting working on this code and I have this so far but I am stuck on how to compare the 2 dataviews to see if they have values that match.  I am also stuck on how to get ALL the thursday games because its only retrieving 1 from the table and their is 2 of them .  any help is greatly apreciated.

 

        ''''''validate if a thursday game is picked
        'gets all thursday games from database and stores it in a string
        Dim thurGames As String
        Dim dvThurGames As DataView
        SqlDataThursdayGames.SelectParameters("thur").DefaultValue = "1"
        dvThurGames = CType(SqlDataThursdayGames.Select(DataSourceSelectArguments.Empty), DataView)
        thurGames = CType(dvThurGames.Table.Rows(0)(0), String)

        'gets current user picks
        Dim dvPicks As DataView
        Dim curPicks As String
        dvPicks = CType(SqlDataSourceCurrentPicks.Select(DataSourceSelectArguments.Empty), DataView)


        'checks to see if user picks a thursday game
        'if so we disable a dropdownlist and set its value = team
 

 

0
cluce
7/14/2008 12:51:25 AM

for what its worth here is my solution.

        sdsPickThur.SelectParameters("game1").DefaultValue = "N.Y. Giants"
        sdsPickThur.SelectParameters("game2").DefaultValue = "Washington"
        sdsPickThur.SelectParameters("UserID").DefaultValue = Membership.GetUser.ProviderUserKey.ToString
        Dim dvthurGames As DataView
        Dim thur1Games As String

        dvthurGames = CType(sdsPickThur.Select(DataSourceSelectArguments.Empty), DataView)
        gvThur.DataBind()

        If gvThur.Rows.Count >= "1" And DateTime.Now >= DateTime.Parse("7/15/2008 10:00 AM") Then
            thur1Games = CType(dvthurGames.Table.Rows(0)(1), String)
            ddlPick1.Items.Clear()
            ddlPick1.Items.Add(thur1Games)
            ddlPick1.SelectedItem.Text = thur1Games
            pick1 = ddlPick1.SelectedItem.ToString
            ddlPick1.Enabled = False
0
cluce
7/14/2008 11:28:40 PM
Reply: