0

I am using a dataset to create a combined table and display it in a datagridview. So far I get the columns but no data under those columns. The database is a SQLite and using two tables to get the needed data. Table 1 contains a sample_id field with other data and Table 2 contains a sample_id field too and two other fields, one is size (1-100) and particle_data. So it looks like this (sample_id, size, data => 12 1 10 | 12 2 11 | 12 3 8 | 12 4 9 etc.)

This is the dataset creation:

Dim dataCombined As DataSet = New DataSet
    dataCombined.Tables.Add(queryResult)
    dataCombined.Tables.Add(particleQuery)
    dataCombined.Relations.Add("combinedSource", queryResult.Columns("sample_id"), particleQuery.Columns("sample_id"))
    For i As Integer = 1 To 100
        queryResult.Columns.Add(i.ToString(), GetType(Integer))
     Next i
SearchResults.DataSource = dataCombined.Tables(0)

The display:

For item As Integer = 1 To 100
    SearchResults.Columns(item.ToString()).HeaderText = item.ToString()
Next item

So the problem is column headers displayed, but no data under them. My guess is I need to provide somehow the data to display, but no idea how can I achieve it.

Smita Ahinave
  • 1,901
  • 7
  • 23
  • 42
Paxsentry
  • 193
  • 2
  • 14

1 Answers1

0

After a long research found this post and it provided the solution:

Merging 2 data tables in vb.net

A little modification according to the https://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter(v=vs.110).aspx documentation(the single quotes needed):

dv.RowFilter = (sKey & " = '" & row(sKey).ToString() & "'")
Community
  • 1
  • 1
Paxsentry
  • 193
  • 2
  • 14