3
Reply

Return datatable

Phuc Hoang

Phuc Hoang

Dec 1 2010 8:22 PM
2.1k
Hello Everybody
How can i return database that using  SELECT
Here is  my code

   Public Function Recommened_GetUser(ByVal UserID As Integer, ByVal Path As String) As Data.DataTable
                Dim dataset As New Data.DataSet
                dataset.ReadXml(Path & filename)
                Dim dt_ret As DataTable
                Dim table As DataTable = dataset.Tables("Recommendhotel")
                ' Presuming the DataTable has a column named Date.
                Dim expression As String
                expression = "UserID='" & UserID & "'"
                Dim foundRows() As DataRow
                ' Use the Select method to find all rows matching the filter.
                foundRows = table.Select(expression)
                Dim i As Integer
                ' Print column 0 of each returned row.
                For i = 0 To foundRows.GetUpperBound(0)
                    dt_ret = foundRows(i)(0) // I want to return datatable
                Next i
                Return dt_ret
            End Function
I want to select that only show depend on condition (UserID)

I really appreciate all the help you can give me!
Thanks in advance

Phuc Hoang

Answers (3)