Data Table Select function does not return rows

  • Thread starter Thread starter Tariq Hasan
  • Start date Start date
T

Tariq Hasan

Guest
I have created a string array which stores selected column names of sql server dataTable named "Parameter Values" in vb.net. I want to display records of selected column to a datagridview. I have created a temporary table 'dtTable' consisting of selected column name taken from the array. Then I have tried to use data Table 'Select' function to get the record from my main table [Parameter Values] and tried to transfer the values to the temp table 'dtTable'. The datagridview displays the dtTable column names correctly but no records are displayed. Any assistance will be highly appreciated.


Dim para(2) As String
para(0) = "Record ID"
para(1) The = "Project ID"
para(2) = "w74ax"
Dim i, j As Integer
Dim dtTable As New DataTable
For i = 0 To 2
dtTable.Columns.Add(para(i), GetType(String))
Next
Try
Dim res() As
DataRow = Main_DataDataSet.Tables("Parameter Values").Select("w74ax >= 0")


MsgBox(res.Count)

For i = 0 To res.GetUpperBound(0)
For j = 0 To 2
dtTable.Rows(i)(j) = res(i).Item(para(j))
Next
dtTable.Rows.Add(res)
Next
Me.DataGridView2.DataSource = dtTable
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try



Continue reading...
 
Back
Top