CodeSmith Community
Your Code. Your Way. Faster!

Can table column enums become zero based?

Latest post 10-04-2006 2:58 PM by Robert Hinojosa. 3 replies.
  • 10-03-2006 7:54 AM

    • Mammaplank
    • Not Ranked
    • Joined on 09-12-2006
    • The Netherlands
    • Posts 4
    • Points 140

    Can table column enums become zero based?

    Hi,

    Is there any way to let NetTiers generate zerobased column enums? I use the column enum to retrieve data from dataset records, but there the column names are zero based.

    For example, table Users:
      UserId
      UserName
      UserPassword

    Creates enum:
      [EnumTextValue("UserId")]
      [
    ColumnEnum("UserId", typeof(System.Int32), System.Data.DbType.Int32, true, true, false)]
      UserId= 1,
     
      [EnumTextValue("UserName")]
      [
    ColumnEnum("UserName", typeof(System.Int32), System.Data.DbType.Int32, true, true, false)]
      UserName=2,
      [EnumTextValue("UserPassword")]
      [
    ColumnEnum("UserPassword", typeof(System.Int32), System.Data.DbType.Int32, true, true, false)]
      UserId= 3

     Now, i have a custom stored procedure, _Users_GetByPassword. This SP can return a dataset. If i create a loop for each record within the resulting table and want to display the username, it could be something like this:

     foreach(datarow r in GetByPassword('gjdfjsgjsdjg').Tables[0].Rows)
    {
      response.write(r[UsersColumn.UserName].ToString());
    }

    But UserColumn.Username will result into column 2. Because the columns within the row are zero based, this would return the user password instead. This would be solved if the generated enum could also be zero based... because i'm new at NetTiers it could well be that there is a way more easy sollution for this, offcourse i would be happy to hear from :-)

     Thanks for any response!

    • Post Points: 35
  • 10-03-2006 4:45 PM In reply to

    Re: Can table column enums become zero based?

    I do believe there are some dependancies in the reason we did it this way.  But we'll dig through the code and make sure.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    Filed under:
    • Post Points: 35
  • 10-04-2006 2:50 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Can table column enums become zero based?

    I think it had something to do with using the Column Enum's int value in an ORDER BY clause.  (e.g. ORDER BY 1).

    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 35
  • 10-04-2006 2:58 PM In reply to

    Re: Can table column enums become zero based?

    Yep, that was it.

    On 10/4/06, bdiaz <bounce-bdiaz@codesmithsupport.com> wrote:
    I think it had something to do with using the Column Enum's int value in an ORDER BY clause.  (e.g. ORDER BY 1).





    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems