• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

populate dataset

Hello,

 I want to populate this data to the dataset

        Dim FileName As String
        Dim FileAlias As String
        Dim FileUrl As String
        Dim SysDate As String

        FileName = Session("FileName").ToString
        FileAlias = Session("FileAlias").ToString
        FileUrl = Session("FileUrl").ToString
        SysDate = Session("SysDate").ToString

What I need is create columns in the data set named filename, filealias, fileurl, sysdate
and everytime there is data in these variables I need to fill it in the dataset and then populate the datagrid with this data

Thanks,
Rahul
0
rahulnimje
Asked:
rahulnimje
  • 2
1 Solution
 
b1xml2Commented:
Public NotInheritable Class DataSetCollectionBase
      Private Sub New
      End Sub
      
      Private Shared sessionTable As DataTable
      
      Public Shared Function NewSessionTable() As DataTable
            If sessionTable Is Nothing Then
                  sessionTable = New DataTable("Session")
                  With sessionTable.Columns
                        .Add("FileName",GetType(String))
                        .Add("FileAlias",GetType(String))
                        .Add("FileUrl",GetType(String))
                        .Add("SysDate",GetType(String))
                  End With
            End If
            Return sessionTable.Clone()
      End Function


End Class
0
 
b1xml2Commented:
Dim ds As New DataSet()
Dim table As DataTable = DataSetCollectionBase.NewSessionTable()
ds.Tables.Add(table)
'first way
table.Rows.Add(New Object [] { Session("FileName").ToString, Session("FileAlias").ToString, Session("FileUrl").ToString, Session("SysDate").ToString})
'second way
Dim row As DataRow = table.NewRow()
row("FileName") = "yadda"
row("FileAlias") = "x"
row("FileUrl") = "gsgs"
row("SysDate") = "dada"
table.Rows.Add(row)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now