473,230 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Typed dataset confusion

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. If I used the
typed objects, I get zero rows. If I use the standard ones, I get 21 rows.

Also, I notice that my HoldingsDataSet object has a member named Holdings.
What data type is that member and what is it for?

Thanks very much!

Rob
Nov 20 '05 #1
2 920
You need to fill the specific table explicitly by name or the Typed table
name must match the database table name. Looks like you are doing none of
the above. Also, you are defeating the purpose of using a Typed DataSet by
using an ordnial index, just use the class as it is supposed to be:

______________________________________________

holdingsAdapter.SelectCommand = New OleDbCommand _
("SELECT * FROM Holdings", mDB)
holdingsAdapter.Fill(holdingsSet)

'// This is very bad:
'// holdingsTable = holdingsSet.Tables(0)
'// MgBox("Rows: " & holdingsTable.Rows.Count)

'// Use this instead:
Msgbox("Rows: " & holdingsSet.HoldingTable.Rows.Count)
_____________________________________________

For more info, see the section in the .NET help docs titled, "Using Typed
Datasets", or the ADO.NET group:

microsoft.public.dotnet.framework.adonet

HTH,
Jeremy

Nov 20 '05 #2
Cor
Hi Rob,

If this is all your code than you can make it much simpler
(I asume that mDB is your connection)
Dim holdingsAdapter As New OleDbDataAdapter()
Dim holdingsSet As New HoldingsDataSet()

holdingsAdapter.SelectCommand = New OleDbCommand _
("SELECT * FROM Holdings", mDB)
The adapter creates the schema and constrains from your select
holdingsAdapter.Fill(holdingsSet) If you want you can name the table and use
holdingsAdapter.Fill(holdingsSet,"Holdings")
this is not real necessary with one table
holdingsTable = holdingsSet.Tables(0)
MsgBox("The holdings table has " & holdingsTable(0).Rows.Count & " rows.")

I hope this helps?

Cor
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
I am confused how strongly typed dataset is different from un-typed dataset. Is there any good link explaining pros and cons of both? Which one should be used preferably?
1
by: Nedu N | last post by:
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the further...
1
by: Trond | last post by:
I have a class MessageController that has a method GetMessagesDataset that connects to a database SPROC. When done it returns a dataset. Then in my ASP.NET for i do this: msgController = new...
12
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
1
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't...
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.