add columns/fields to db

Last post 05-23-2008 2:16 PM by tonian. 3 replies.

Sort Posts:

  • add columns/fields to db

    05-22-2008, 8:09 PM
    • Loading...
    • tonian
    • Joined on 04-30-2008, 5:42 PM
    • Posts 29

    i need to add a column to the item data.  i've added it in the table itself, just an nvarchar, and gone through the App_Code files item.vb, sqlcatalogprovider.vb adn category.vb and basically just duplicated what's in those files for the "description" column.  i placed the column, both in the table and in the .vb pages, in the same order, right before the "description" column/references.

    when i run it, i get an error:

    IndexOutOfRangeException was unhandled by user code

    code

    and it points to a line in SqlCatalogProvider.vb:

    curr.Code = Util.ReturnEmptyStringIfDbNull(r("code"))

    which is a line i added above the same line for "description".  the tips on the error refer to index issues that in my limited experience i'm not familiar with.

    can anyone help me sort this out or point me to something that'll help get past this?  i've looked over the forum and found a number of posts about adding columns to the DisplayAd starter kit but I couldn't quite apply them, and I've seen other's finished work which sure looks like they've added columns but i haven't seen how they did it.

    much appreciated.

  • Re: add columns/fields to db

    05-22-2008, 11:37 PM
    • Loading...
    • tonian
    • Joined on 04-30-2008, 5:42 PM
    • Posts 29

    more info, the full error is:

     

    itemCode

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IndexOutOfRangeException: itemCode

    Source Error:

    Line 93:                 End If
    Line 94:                 curr = New Category(CStr(r("id")), CType(r("visible"), [Boolean]), CStr(r("title")))
    Line 95:                 curr.itemCode = Util.ReturnEmptyStringIfDbNull(r("itemCode"))
    Line 96:                 curr.Description = Util.ReturnEmptyStringIfDbNull(r("description"))
    Line 97:                 curr.ImageUrl = Util.ReturnEmptyStringIfDbNull(r("imageUrl"))

    Source File: C:\Websites\smlbzqsk\App_Code\Catalog\SqlCatalogProvider.vb    Line: 95

    Stack Trace:

    [IndexOutOfRangeException: itemCode]
       System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +1433771
       System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +102
       System.Data.SqlClient.SqlDataReader.get_Item(String name) +12
       SqlCatalogProvider.GetChildCategories(String parentCategoryId) in C:\Websites\smlbzqsk\App_Code\Catalog\SqlCatalogProvider.vb:95
       Catalog.GetChildCategories(String parentCategoryId) in C:\Websites\smlbzqsk\App_Code\Catalog\Catalog.vb:43
       ItemsPage.Page_Load() in C:\Websites\smlbzqsk\Items.aspx.vb:28
       System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) +5
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +858603
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
    

  • Re: add columns/fields to db

    05-22-2008, 11:49 PM
    • Loading...
    • tonian
    • Joined on 04-30-2008, 5:42 PM
    • Posts 29

    oops, i should say i changed the name of the column from "code" to itemCode" in case that word was reserved.

    thanks again.

  • Re: add columns/fields to db

    05-23-2008, 2:16 PM
    Answer
    • Loading...
    • tonian
    • Joined on 04-30-2008, 5:42 PM
    • Posts 29

    um... nevermind

    turns out, in my amature zeal, i added the new column reference to a section of the vb code that was looking for *category* info, being confused by the similarity between the names of the columns in those two tables and the layout of the sections in the vb code.  deleted the line and it's back to working fine.

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter