R
Rob Richardson
Greetings!
I have a database with a table named Holdings. I has VB.Net create a .xsd
file for it so that I could use a typed dataset with it. The table has 21
rows. If I use ordinary datasets, I get a DataTable object with 21 rows.
If I use a typed dataset, I get a HoldingTable object with 0 rows. What am
I doing wrong? Here's the code:
Dim holdingsAdapter As New OleDbDataAdapter()
Dim holdingsSet As New HoldingsDataSet()
Dim holdingsTable As HoldingsDataSet.HoldingsDataTable
Dim holdingsRow As HoldingsDataSet.HoldingsRow
'Dim holdingsSet As New DataSet()
'Dim holdingsTable As DataTable
'Dim holdingsRow As DataRow
holdingsAdapter.SelectCommand = New OleDbCommand _
("SELECT * FROM Holdings", mDB)
holdingsAdapter.Fill(holdingsSet)
holdingsTable = holdingsSet.Tables(0)
MsgBox("The holdings table has " & holdingsTable.Rows.Count & " rows.")
This code is in a Try block, and no exceptions are thrown.
Also, I notice that my HoldingsDataSet object has a member named Holdings.
Is that member an instance of type HoldingsDataTable, like I think it is?
Thanks very much!
Rob
P.S. I have already been told that using "Tables(0)" defeats the purpose of
a typed dataset. That's not the point here. Once I know I can get the data
I need into the typed dataset, I'll switch over to using it the way it's
supposed to be used.
I have a database with a table named Holdings. I has VB.Net create a .xsd
file for it so that I could use a typed dataset with it. The table has 21
rows. If I use ordinary datasets, I get a DataTable object with 21 rows.
If I use a typed dataset, I get a HoldingTable object with 0 rows. What am
I doing wrong? Here's the code:
Dim holdingsAdapter As New OleDbDataAdapter()
Dim holdingsSet As New HoldingsDataSet()
Dim holdingsTable As HoldingsDataSet.HoldingsDataTable
Dim holdingsRow As HoldingsDataSet.HoldingsRow
'Dim holdingsSet As New DataSet()
'Dim holdingsTable As DataTable
'Dim holdingsRow As DataRow
holdingsAdapter.SelectCommand = New OleDbCommand _
("SELECT * FROM Holdings", mDB)
holdingsAdapter.Fill(holdingsSet)
holdingsTable = holdingsSet.Tables(0)
MsgBox("The holdings table has " & holdingsTable.Rows.Count & " rows.")
This code is in a Try block, and no exceptions are thrown.
Also, I notice that my HoldingsDataSet object has a member named Holdings.
Is that member an instance of type HoldingsDataTable, like I think it is?
Thanks very much!
Rob
P.S. I have already been told that using "Tables(0)" defeats the purpose of
a typed dataset. That's not the point here. Once I know I can get the data
I need into the typed dataset, I'll switch over to using it the way it's
supposed to be used.