Re: Using Strongly Typed Datasets
- From: ctilly@xxxxxxxxx
- Date: 14 Aug 2006 16:25:07 -0700
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.
.
- References:
- Using Strongly Typed Datasets
- From: ctilly
- Re: Using Strongly Typed Datasets
- From: Cor Ligthert [MVP]
- Using Strongly Typed Datasets
- Prev by Date: Re: refresh from DataGridView to bound DataSet
- Next by Date: OleDB Stored Procedure returns Data Rows
- Previous by thread: Re: Using Strongly Typed Datasets
- Next by thread: ContextSwitchDeadlock was detected
- Index(es):
Relevant Pages
|
|