Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

(for the purpose of this question, there are three columns in this table, 'Action_ID', 'Type_ID', 'Task_Parameter')

I want to create a dataview where only those Action_ID's where type_id = 5 are going to be edited and compared.

If multiple rows exist in this dataview where Type_ID = 5 and "Task_Parameter" is identical to any other row, then I only want to keep the row with the highest Action ID.

Here is what I have so far

 

Dim objConn As SqlConnection = New SqlConnection(Connection) 
       Dim myActionCMD As SqlCommand = New SqlCommand("xxx" , objConn) 

       Dim myActionDA As New SqlClient.SqlDataAdapter() 
       Dim myActionDS As New DataSet() 


       myActionDA.SelectCommand = myActionCMD 
       myActionDS.Clear() 
       myActionDA.Fill(myActionDS, "ActionTable") 

       Dim sRowFilter As String = "Type_ID = 5" 
       Dim sRowSort As String = "Action_ID" 
       Dim dvCarepath As New DataView(myActionDS.Tables("ActionTable"), sRowFilter, sRowSort, DataViewRowState.ModifiedCurrent)

 

any help on how to go about doing this is greatly appreciated.

  • *Experts*
Posted

Hmm... I don't know of any way to get the built-in DataView to limit rows to distinct rows. If you need this distinct view for binding purposes, I think you may have to go another route such as creating a new DataSet with the filtered data or use a custom binding object such as the JoinView. The JoinView is a new object that MS wrote, available through MSDN online for free, that shows how to implement a new DataView-like object. You can use it to bind to a JoinView object which would show two tables in a DataSet as one table for binding purposes (such as showing parent/child data in one row).

 

If you have to go a custom route, at least there's that sample which shows how to create a bindable object. :p

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...