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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ADOX making me crazy, please help

ADOX making me crazy, please help

Scheduled Pinned Locked Moved C#
databasehelp
1 Posts 1 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.
  • P Offline
    P Offline
    perry59
    wrote on last edited by
    #1

    Im trying to create an access database with ADOX. It is to contain 3 tables, each with a primary and foreign key and a one-to-one relationship between each table. I have no problem creating and populating the tables, no problem adding indexes to each table (one index is also a primary key). When I try to add primary keys to any tables that do not already have one, it bombs out. I've scoured everything I can find on ADOX (most of its VB) and nothing helps and some examples I found were bad or confusing. I'm also not sure if simply creating the primary/foreign keys will create a relationship of if there is something else I must do. I've posted my code below with comments on the problem areas, I appreciate any help (while I still have hair left) ! ------------------------------------------------------------------------------- /// /// Create new database file /// /// public static void CreateDb(string fileName) { // append function prototype // Append(object Item, ADOX.KeyTypeEnum Type, object Column, string RelatedTable, string RelatedColumn) ADOX.CatalogClass cat = new ADOX.CatalogClass(); ADOX.Table tblNew = new ADOX.Table(); ADOX.Index tblIdx = new ADOX.Index(); ADOX.Key tblKey = new ADOX.Key(); // Create database and add tables try { cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Jet OLEDB:Engine Type=5"); // Create the CUSTOMERS table tblNew.Name = "Customers"; tblNew.ParentCatalog = cat; tblNew.Columns.Append("CustomerID", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("MachineType", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Name", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Address", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("City", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("State", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Zip", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Country", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Status", ADOX.DataTypeEnum.adWChar, 50); cat.Tables.Append(tblNew); tblNew = null; // Create the DRA

    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