G
Guest
Switching from ADO to ADO.net and I am totally lost and and frustrated. What
I'm trying to do is so dirt simple: At RUNTIME, load an arbitrary database
table into a datagrid for editing. Simple: create a SqlDataAdapter,
dynamically constructing the SQL command string based on the the name of the
table supplied at runtime; create a CommandBuilder; call Fill, supplying a
new blank DataSet; call Update when complete. So far, so good.
The table that I'm editing has lookups that the user needs to be able to see
as they are editing. However, there's not updatable view concept in ADO.NET.
If I do a JOIN to any lookup tables, CommandBuilder flatlines and can't
generate the necessary update statements. Is the only alternative here to
generate the update statement by hand? That just seems incredibly tedious and
unnecessary.
Another weird thing is that it's a mystery as to how CommandBuilder works.
If you trace through the code you'll see that it doesn't actually modify the
UpdateCommand property in the DataAdapter. Somehow it's doing it's magic in
the background. This prevented me from kludging up update statements from a
non-lookup version of the SelectCommand and using that in the lookup version.
Another problem is now to specify a primary key for the DataSet. Supposedly
the SqlDataAdapter uses a DataReader in the background to generate schema for
the DataSet. But the IsKey fields are all null. So somewhere between there
and the DataSet it somehow decides what the primary key is, but it's not
accessible to the programmer. I guess what I'm wonder is can I specify a
primary key directly to the DataSet after it has been filled?
I'm trying to do is so dirt simple: At RUNTIME, load an arbitrary database
table into a datagrid for editing. Simple: create a SqlDataAdapter,
dynamically constructing the SQL command string based on the the name of the
table supplied at runtime; create a CommandBuilder; call Fill, supplying a
new blank DataSet; call Update when complete. So far, so good.
The table that I'm editing has lookups that the user needs to be able to see
as they are editing. However, there's not updatable view concept in ADO.NET.
If I do a JOIN to any lookup tables, CommandBuilder flatlines and can't
generate the necessary update statements. Is the only alternative here to
generate the update statement by hand? That just seems incredibly tedious and
unnecessary.
Another weird thing is that it's a mystery as to how CommandBuilder works.
If you trace through the code you'll see that it doesn't actually modify the
UpdateCommand property in the DataAdapter. Somehow it's doing it's magic in
the background. This prevented me from kludging up update statements from a
non-lookup version of the SelectCommand and using that in the lookup version.
Another problem is now to specify a primary key for the DataSet. Supposedly
the SqlDataAdapter uses a DataReader in the background to generate schema for
the DataSet. But the IsKey fields are all null. So somewhere between there
and the DataSet it somehow decides what the primary key is, but it's not
accessible to the programmer. I guess what I'm wonder is can I specify a
primary key directly to the DataSet after it has been filled?