foreign key
-
When I use the Fill method of a DataAdapter it creates the table structure in my dataset. It also brings the PrimaryKey information about that table to the dataset. My question is: is there anyway to bring the "foreign key" information about the table columns ? How can I know which columns are foreign keys and to which table they refer ? thanks Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
English is not my native language so, if you find any spelling erros in my posts, please let me know. -
When I use the Fill method of a DataAdapter it creates the table structure in my dataset. It also brings the PrimaryKey information about that table to the dataset. My question is: is there anyway to bring the "foreign key" information about the table columns ? How can I know which columns are foreign keys and to which table they refer ? thanks Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
English is not my native language so, if you find any spelling erros in my posts, please let me know.See the
DataRelation
class in the .NET BCL. It's pretty straight-forward and easy to make a typedDataSet
by right-clicking on your project (or a folder under your project, which helps set the default namespace for your source files you add to them) and adding a new type, then chooseDataSet
. You can even drag and drop tables, views, and stored procedures from the server explorer to create elements (theDataSet
designer is, after all, just the XML schema designer) that represent tables, while their elements represent fields. You can create primary keys and draw relationships. When you save this, it serializes using theCodeDomSerializer
so that you have source code. When you use it, instead of usingDataSet ds = new DataSet();
, for example, you would useMyDataSet ds = new MyDataSet();
. That already has typed table and fiend names, as well as relationships established. Note, however, that theDataAdapter
derivatives - or rather the command builders likeSqlCommandBuilder
- don't support auto-generation of complex statements required for updating a data source with changes. All this is programmatic changes you can do manually, as well. It's most important to read the documentation, but you might also makes a typedDataSet
in this manner and examine the source code (click "Project->Show Hidden Files" in the menu to see the source file itself). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]