Creating tables through coding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Airslash
    New Member
    • Nov 2007
    • 221

    #1

    Creating tables through coding

    I'm currently building a library to use in .NET for communicating with a database. We're using the nexusDB and they have a basic .NET driver for communicating in the .NET environment, but since we came from borland I'm trying to build some components now that can take over the work we had in Borland.

    So to keep it short, i've build a class called Database, Table and Column that rely on the .NET framework for communication with the database.
    I'm able to create tables based upon the meta data from the database and construct then entire schema of the database in memory.

    I am however looking for a means to adjust a table. E.g if a programmer uses my components to retrieve the structure of a specific table and adds a column to that table through code how we can we submit these changes back to the database?

    i'm aware I will have to make my own SQL generator, but currently I cannot find any means to check in the DataTable object if a column was added aside from the original structure. As far as i know GetChanges() only reflects the changes made to rows, not the structure....
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Why don't you just use the existing DataTable class available in the .NET library?

    When you query databases you are typically returned these objects anyways......

    -Frinny

    Comment

    • Airslash
      New Member
      • Nov 2007
      • 221

      #3
      I know they exist and I'm using them now, but they still don't allow me to perform a restructure on the table or create a new table in the database. Only as memory storage.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        That is very true.
        Have you considered extending this?
        Maybe creating a custom class (as you were going to originally) that inherits from the DataTable?

        Comment

        • Airslash
          New Member
          • Nov 2007
          • 221

          #5
          I'm working on something similar.
          Currently I have wrappers around the various classes to treat the DataTable and DataColumn classes basicly as a container holding meta data and implement my own functionality as class.

          so I use the object to store all the meta data I require and bring it outwards through property mapping.
          Only thing left now for me is creating the SQL generator to perform the create etc based upon the "meta data" which is fairly easy

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Well I'm glad you figured it out :D
            Sounds like an interesting, self aware class

            -Frinny

            Comment

            Working...