|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlDataAdapter.FillSchemaThe SqlDataAdapter.FillSchema method will automatically setup things like the primary keys, auto increment, etc based on the settings on the SQL Server. However, if you create a datatable using the SQL statement that joins together data from multiple data tables, then FillSchema does not work (as much? at all??). For example, if I use the following query: SELECT Material.*, Color.Color AS Color FROM Material INNER JOIN Color ON Color.ColorID = Material.fkColorID FillSchema does not obtain MaterialID, the primary key of the Material table, as the primary key, even though its uniqueness is not affected at all by the JOIN with Color. It is, of course, possible to manually configure primary keys. However, this is not as desirable as the automated FillSchema approach. Is this just the way things are, or is there some trick that I am missing? Thanks, Aaron that is because after a join there is no longer a "primary key" on the
table... you'd have the same problem on the server side too in SQL server... when you alter the DML through the join it ignores keys... Show quoteHide quote "Aaron" <odysseus***@hotmail.com> wrote in message news:1155854003.796724.118490@74g2000cwt.googlegroups.com... > Hi, > > The SqlDataAdapter.FillSchema method will automatically setup things > like the primary keys, auto increment, etc based on the settings on the > SQL Server. However, if you create a datatable using the SQL statement > that joins together data from multiple data tables, then FillSchema > does not work (as much? at all??). For example, if I use the following > query: > > SELECT Material.*, Color.Color AS Color > FROM Material INNER JOIN > Color ON Color.ColorID = Material.fkColorID > > FillSchema does not obtain MaterialID, the primary key of the Material > table, as the primary key, even though its uniqueness is not affected > at all by the JOIN with Color. > > It is, of course, possible to manually configure primary keys. > However, this is not as desirable as the automated FillSchema approach. > Is this just the way things are, or is there some trick that I am > missing? > > Thanks, > Aaron > Aaron,
You be aware that AFAIK a joined table not meant to be updated using that. Cor Show quoteHide quote "Aaron" <odysseus***@hotmail.com> schreef in bericht news:1155854003.796724.118490@74g2000cwt.googlegroups.com... > Hi, > > The SqlDataAdapter.FillSchema method will automatically setup things > like the primary keys, auto increment, etc based on the settings on the > SQL Server. However, if you create a datatable using the SQL statement > that joins together data from multiple data tables, then FillSchema > does not work (as much? at all??). For example, if I use the following > query: > > SELECT Material.*, Color.Color AS Color > FROM Material INNER JOIN > Color ON Color.ColorID = Material.fkColorID > > FillSchema does not obtain MaterialID, the primary key of the Material > table, as the primary key, even though its uniqueness is not affected > at all by the JOIN with Color. > > It is, of course, possible to manually configure primary keys. > However, this is not as desirable as the automated FillSchema approach. > Is this just the way things are, or is there some trick that I am > missing? > > Thanks, > Aaron > Interesting (although mostly useless) loophole:
If a tables primary keys are also the foreign key columns (used to form the joins) then the primary keys will populate correctly. I discovered this on accident. Weird, huh? I am also still on VS 2003. Aaron
Parsing between a character and sysmbol
Best Practice Error Handling Programmatically Crawl a DLL's Namespacec Is there a repeat characters function? A little help with an array & 'NullReferenceException was unhandled' ?? VB 2005 Syntax A windows service question Data Binding with CSV Files String function in VB VB6: send active hyperlink in body of email sent in VB6 |
|||||||||||||||||||||||