Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. foreign key

foreign key

Scheduled Pinned Locked Moved C#
questionc++com
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mauricio Ritter
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • M Mauricio Ritter

      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.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      See the DataRelation class in the .NET BCL. It's pretty straight-forward and easy to make a typed DataSet 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 choose DataSet. You can even drag and drop tables, views, and stored procedures from the server explorer to create elements (the DataSet 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 the CodeDomSerializer so that you have source code. When you use it, instead of using DataSet ds = new DataSet();, for example, you would use MyDataSet ds = new MyDataSet();. That already has typed table and fiend names, as well as relationships established. Note, however, that the DataAdapter derivatives - or rather the command builders like SqlCommandBuilder - 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 typed DataSet 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]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups