A
Alienka
I have a problem with a typed dataset.
First I wrote a simple program that fetched one table from SQL Server
2000 to an UNTYPED dataset. Let's say, the table was called Table.
1. I added an untyped dataset in designer
2. I added a table to the dataset, called it Table
3. I added columns to Table in designer, so that they exactly matched
those in database
4. I added a datagrid to the form and set Table as source
5. Finally, I added some textboxes to the form and set bindings for
them to columns of Table, everything in designer
I filled the dataset using dataadapter and everything worked very well:
when I changed current row in datagrid, textboxes changed their values
to those from the current row.
And then I wrote another program. I created a TYPED dataset (from an
xsd file) that exactly matched the previous one (columns, types,
constraints etc). The only difference was it was typed (so inherited
after a dataset) and I no longer needed to type in columns manually.
1. I added the typed dataset in designer
2. I didn't have to add any tables to it, it already had Table with all
the necessary columns
3. I added a datagrid to the form and set typedDataSet.Table as source
5. Finally, I added some textboxes to the form and set bindings for
them to columns of typedDataSet.Table, everything in designer
And now, that's the point. It didn't work at all. I filled the dataset
with datadapter. When I changed current row in datagrid, values in
textboxes didn't refresh, as if textboxes were bound to the first row
in Table forever.
My question is: what did I do wrong? I guess typed dataset inherits ALL
benefits of an untyped one, so why binding works with an untyped
dataset, but stops working whenever I change the untyped dataset to
it's strongly typed equivalent? It's not the only program where I have
this problem. I encounter this problem in every project where I use a
typed dataset. Please help, I keep looking at the code but I can't see
anything "suspicious". And I keep looking for a solution in Google, but
can't find anything that could help me.
Thak you in advance!
First I wrote a simple program that fetched one table from SQL Server
2000 to an UNTYPED dataset. Let's say, the table was called Table.
1. I added an untyped dataset in designer
2. I added a table to the dataset, called it Table
3. I added columns to Table in designer, so that they exactly matched
those in database
4. I added a datagrid to the form and set Table as source
5. Finally, I added some textboxes to the form and set bindings for
them to columns of Table, everything in designer
I filled the dataset using dataadapter and everything worked very well:
when I changed current row in datagrid, textboxes changed their values
to those from the current row.
And then I wrote another program. I created a TYPED dataset (from an
xsd file) that exactly matched the previous one (columns, types,
constraints etc). The only difference was it was typed (so inherited
after a dataset) and I no longer needed to type in columns manually.
1. I added the typed dataset in designer
2. I didn't have to add any tables to it, it already had Table with all
the necessary columns
3. I added a datagrid to the form and set typedDataSet.Table as source
5. Finally, I added some textboxes to the form and set bindings for
them to columns of typedDataSet.Table, everything in designer
And now, that's the point. It didn't work at all. I filled the dataset
with datadapter. When I changed current row in datagrid, values in
textboxes didn't refresh, as if textboxes were bound to the first row
in Table forever.
My question is: what did I do wrong? I guess typed dataset inherits ALL
benefits of an untyped one, so why binding works with an untyped
dataset, but stops working whenever I change the untyped dataset to
it's strongly typed equivalent? It's not the only program where I have
this problem. I encounter this problem in every project where I use a
typed dataset. Please help, I keep looking at the code but I can't see
anything "suspicious". And I keep looking for a solution in Google, but
can't find anything that could help me.
Thak you in advance!