Adding data and a session containing data

I have a session that contains a datatable, as well as a function that returns a datatable. I need to add these two. How can i do this?

The following code should be replaced with the correct code.

Session("Table")=Session("Table")+obj.GetCustomer()

... where obj is a business-level object.

The + sign cannot be used to add these two, so how can I do this?

+3
source share
3 answers

I would try something like this:

Dim MyDataSet1 As New DataSet()
Dim MyDataSet2 As New DataSet()

Dim dt1 As New DataTable() = ctype(Session("Table"), DataTable)
Dim dt2 As New DataTable() = obj.GetCustomer()

MyDataSet1.Tables.Add(dt1)
MyDataSet2.Tables.Add(dt2)

MyDataSet1.Merge(MyDataSet2)

Session("Table") = MyDataSet1.Tables(0)

Chris

+2
source

in C #:

Session ["Table"] = ((DataSet) Session ["Table"]). Merge (obj.GetCustomer ());

+1
source

( ..), . . , , .

-sa

0

Source: https://habr.com/ru/post/1731154/


All Articles