Results 1 to 2 of 2

Thread: [RESOLVED] [2005] Get New Dataset from Multiple Selection On Datagridview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Resolved [RESOLVED] [2005] Get New Dataset from Multiple Selection On Datagridview

    I want to create a dataset deriving it from a multiple selection of rows on my datagridview.
    What i do is to get a list of IDs for the selectecd records, but i am failing to re-use the Ids to create another dataset which i want to reuse.

    'Declaration of an array of strings
    VB Code:
    1. Public mySeq As New List(Of String)
    2.  
    3. 'This stores an array of strings that consist of NewSequency values for
    4.     'The Records Selected In The Datagridview
    5.     Public Sub getArrayOfSequencyValues()
    6.         dtInc = dsOrgs.Tables(0)
    7.         For i As Integer = 0 To dtInc.Rows.Count - 1
    8.             drInc = dtInc.Rows(i)
    9.             If Me.dgvIncidents.Rows(i).Selected = True Then
    10.                 'Add the NewSequency Value Of The Record To An Array Of Strings
    11.                 mySeq.Add(drInc.Item("NewSequency"))                
    12.             End If
    13.         Next i
    14.     End Sub

    I thought i would create the dataset this way but this gives me back a dataset with one record only even if i have selected more than one.

    Any Idea will is appreciated.
    VB Code:
    1. Dim noRows As Integer = 0
    2.         For Each seq As String In mySeq
    3.             While noRows < mySeq.Count
    4.                 strSQL = "SELECT [NewSequency],[Easting],[Northing] FROM Incidents WHERE([NewSequency]='" & seq & "')"
    5.                 dsOrgs = connMger.ReturnOleDbData(strAccessConn, strSQL, "Incidents")
    6.                 noRows += 1
    7.             End While
    8.         Next seq
    9.         dtInc = dsOrgs.Tables(0)
    10.         MsgBox(dtInc.Rows.Count)

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: [RESOLVED] [2005] Get New Dataset from Multiple Selection On Datagridview

    Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width