CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2003
    Location
    North Carolina
    Posts
    57

    Auto Generation Database Accessor Methods

    I'm not sure if this is even the right forum for this question. Using the tools provided with Visual Studio.Net, is there a way to create a class file from a database table where the SET and GET method accessors are automatically generated?

    Here is what I'm trying to do. I have a third party rule engine that I'm using for data validation of our client's data that we import into our database. Since each rule needs to operate on one row of data, I'm creating a class for each table and accessor methods for each column within that table. Therefore, when the business users create their rules, they can refer to the lastname column in the employee table as Employee.LastName. I've got about 30 tables and a little over 300 columns. I prefer not to have to code every function by hand. It seems like an easy enough process to generate this type of class so I think somebody should have had this requirement before. Does anyone know of a way to automatically generate these classes, properties, and methods?

    Thanks,
    Mark Brown

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    I am not sure any of the VS.NET wizard directly does that. how ever you can create a form and put a datagrid
    by that again you have to assign sqlcommand, datasource, databinding anyways...

    another thing which reminds me ,
    check out ,

    1) other projects in Project creation in VS.NET IDE
    2) take DataBase Project
    check out and let me know if it works for u


    thanx
    Paresh

  3. #3
    Join Date
    Feb 2003
    Location
    North Carolina
    Posts
    57
    Thanks for the reply. I looked at the Database Project and unfortunately, it won't work. I have seen, in some other forums, where people have created some utilities to do this. However, I have been unable to contact any of them. I could write this myself but, I was hoping to not have to do that. I'm on a tight deadline as is. Has anyone here written a similar utility in C# because apparently there is no way to do this with the tools provided in VS.Net.

    Thanks,
    Mark Brown

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    why don't you search for VS.NET Wizards that can be installed and does the simillar purpose. I remember I had downloaded some wizards (.viz or something) file and just invoking it helps and navigates the project creation. i think you need that..

    -Paresh

  5. #5
    Join Date
    Jun 2001
    Location
    Sweden
    Posts
    11

    Had the same problem :P

    Had the same problem, it's a pain to make 300+ classes or interfaces. So i made my own program to generate the code, this program is made for MS Access my you can prb modify it to suit you.
    Attached Files Attached Files

  6. #6
    Join Date
    Feb 2003
    Location
    North Carolina
    Posts
    57
    Thanks, WarWolf.
    I just finished my own version of this utility yesterday. I have yet to test it though. I converted what someone else did in VB.Net and then cleaned it up for C#. However, the utility is only a command line program. I may yet use your utility as a model to add a user interface to my utility. I really appreciate your help. I'll try to upload my version to this thread when I've finished testing it.

    Mark

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    Lightbulb


    shadow..
    could you post the utility.. would like to see it.
    apreciate it.

    paresh

  8. #8
    Join Date
    Feb 2003
    Location
    North Carolina
    Posts
    57
    Attached is the zip file of the utility. I've tested it to generate "*.cs" files. However, I haven't tested yet to see how those classes work yet. As I do some more testing, I may post some enhancements here. If anyone else enhances this, I'd appreciate seeing them.

    Mark
    Attached Files Attached Files

  9. #9
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890

    Lightbulb

    GREAT !!!
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured