Re: Using Strongly Typed Datasets



Cor, thank you for your response. I am very interested in checking out
the links you provided, but the vb-tips.com site seems to be having
some problems since I can't seem to access it. Once the site comes up
I will check out what these articles have to say.

Again, thank you for your resonse.

Chuck


Cor Ligthert [MVP] wrote:
CTilly,

Be aware that ASPNET and Winforms work and create completely different
styles of strongly typed datasets in Net 2.0. This beneath is about Winforms

In Net 2.0 the handling is more about datatables, a wish often told in past
(not by me).

However by using the DataSource you are able to put those in a dataset.
This simple procedure gives you a great sample of that.

http://www.vb-tips.com/dbpages.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252

About your textbox, setting a text to a textbox is not as simple in Net as
binding the table to the textbox and than use the columname (In this sample
is for simplicity of the sample used a non typed dataset).

http://www.vb-tips.com/dbpages.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8

I hope this helps,

Cor




<ctilly@xxxxxxxxx> schreef in bericht
news:1155320629.030854.152900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am interested in using strong typed datasets, but I am having some
difficulty with some things and was hoping for a little clarification.

I am using VS 2005 (.net 2) and I start off by creating a Dataset to my

project called MyDataset.xsd.

In my Dataset I added a TableAdapter called Products, which resulted in

the creation of a TableAdapter named ProductsTableAdapter and a
DataTable named Products.

So far so good.

What I thought strongly typed datasets would allow me to do is write
code like this....

MyDataset mds = new MyDataset();
mds.ProductsTableAdapter.Fill(mds.Products);

or even better yet...

MyDataset mds = new MyDataset();
mds.Products.GetData();
Textbox1.Text = mds.Products.Rows[1]["ProductName"];

And if I add another query to the DataAdapter such as
"FillByProductID,GetDataByProductID (@ProductID)" then I could say
something like...

MyDataset mds = new MyDataset();
mds.Products.GetDataByProductID(someInt);
Textbox1.Text = mds.Products.Rows[1]["ProductName"];

Now I know the methods I am invoking are TableAdapter methods and not
DataTable methods. However, what the DataSet Designer seems to be
doing is "binding" the TableAdapter to the DataTable. It seems like
that coupling of the TableAdapter with the DataTable should abstract
the TableAdapter and make it so you can get at the data via the
DataTable directly without having to also worry about the TableAdapter.


Instead I find I have to use very cumbersome code, and not at all
intuitive, to get at my data in the MyDataset.

using MyDatasetTableAdapters; // <== THIS TOOK A WHILE TO FIGURE OUT
<snip>
ProductsTableAdapter pta = new ProductsTableAdapter();
DataTable mydt = pta.GetData();
Textbox1.Text = mydt.Rows[1]["ProductName"].ToString(); // <==
STRONGLY TYPED???

So what am I doing wrong? Is there a way to do what I want to do and I

am just going about it all wrong? Or are Visual Studio Datasets just a

waste of time? Because the data doesn't seem strongly typed if I have
to access via the TableAdapter. What am I missing here?

Regards.


.



Relevant Pages

  • Re: Using Strongly Typed Datasets
    ... In Net 2.0 the handling is more about datatables, a wish often told in past ... In my Dataset I added a TableAdapter called Products, ... MyDataset mds = new MyDataset; ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Select Value From Specific Table Column in TableAdapter
    ... A TableAdapter holds no data, it adapts data in a datatable. ... A datatable is a part of a dataset (there are more datatables in a dataset). ... set in the forms of a tableadapter and a bindingnavigator. ... "itemtype" column is so I can customize the information on the form. ...
    (microsoft.public.dotnet.languages.vb)
  • Using Strongly Typed Datasets
    ... I am interested in using strong typed datasets, ... In my Dataset I added a TableAdapter called Products, ... MyDataset mds = new MyDataset; ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Strongly typed datasets: Can table adapter handle multiple resultsets?
    ... But the tableadapter handles in this case everytime single resultsets and therefore it is another situation then your question. ... DataTables in a DataSet. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.adonet)
  • Using Strongly Typed Datasets
    ... I am interested in using strong typed datasets, ... In my Dataset I added a TableAdapter called Products, ... MyDataset mds = new MyDataset; ...
    (microsoft.public.data.ado)