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:
Public mySeq As New List(Of String) 'This stores an array of strings that consist of NewSequency values for 'The Records Selected In The Datagridview Public Sub getArrayOfSequencyValues() dtInc = dsOrgs.Tables(0) For i As Integer = 0 To dtInc.Rows.Count - 1 drInc = dtInc.Rows(i) If Me.dgvIncidents.Rows(i).Selected = True Then 'Add the NewSequency Value Of The Record To An Array Of Strings mySeq.Add(drInc.Item("NewSequency")) End If Next i 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:
Dim noRows As Integer = 0 For Each seq As String In mySeq While noRows < mySeq.Count strSQL = "SELECT [NewSequency],[Easting],[Northing] FROM Incidents WHERE([NewSequency]='" & seq & "')" dsOrgs = connMger.ReturnOleDbData(strAccessConn, strSQL, "Incidents") noRows += 1 End While Next seq dtInc = dsOrgs.Tables(0) MsgBox(dtInc.Rows.Count)




Reply With Quote