Reputation: 13
I have a sqlDataSource that runs a stored procedure that returns a table of the days of the month that was passed in as a parameter, arranged as they would in a calendar. It also returns a second table which contains the event details associated with certain days of the month.
Basically, how would I go about accessing the values contained in the 2nd table that is returned by my query?
I have tried putting the result of the .select in a dataset, unfortunately I get a cast error. If I try to put it in a dataview, I only get the first table.
Any help would be appreciated!
This is what I have right now:
Dim ds As New Data.DataSet
Dim eventTable As New Data.DataTable
ds = sqlCalendrier.Select(DataSourceSelectArguments.Empty)
eventTable = ds.Tables(1)
Upvotes: 0
Views: 345
Reputation: 11
Get in through the backdoor:
Code example:
Dim dv As DataView = CType(sqlCalendrier.Select(DataSourceSelectArguments.Empty), DataView)
Dim ds As New DataSet() = dv.Table.DataSet
Dim dtDates As DataTable = ds.Tables(0)
Dim dtEvents As DataTable = ds.Tables(1)
I hope it works for you.
Upvotes: 1
Reputation: 4687
Taken from this post:
With cmd
.CommandText = "ProdsAndCusts"
.CommandType = CommandType.StoredProcedure
End With
cn.Open()
myReader = cmd.ExecuteReader()
While myReader.Read()
...
End While
myReader.NextResult()
While myReader.Read()
...
End While
Upvotes: 0
Reputation: 1279
By using the tables collection of the data set instance
Dim ds As New DataSet()
ds = <your data source>
Dim dtDates As New DataTable()
Dim dtEvents As New DataTable()
dtDates = ds.Tables(0)
dtEvents = ds.Tables(1)
Upvotes: 0