New column in table

Dejan

Member
Joined
Aug 5, 2005
Messages
15
Location
Negotino, Macedonia
Programming Experience
Beginner
Hello, i need help. I want to insert another data column in CMRC_Product table. I make it and I change this in code:
In App_Code/Objects/Product.vb
VB.NET:
Private _Type As String       <---#Region "private vars"

    Public Property Type() As String
        Get
            Return _Type
        End Get                                  <---- #Region "Public Props"
        Set(ByVal value As String)
            _Type = value
        End Set
    End Property

  _Type = rdr("Type").ToString     <--- Public Sub Load
In Admin/admin_products.aspx.vb
VB.NET:
  _Type = rdr("Type").ToString               <-- private sub loadeditor
product.Type = txtType.Text                  <--- Protected Sub btnSave_Click
I try to insert my column in App_Code/BLL/Catalogmanager.vb in Public Shared Function AddProduct and Public Shared Sub UpdateProduct but i got error massage:
Exception Details: System.IndexOutOfRangeException: Type
Source Error:

Line 244: _IsActive = CBool(rdr("IsActive"))
Line 245: _DiscountPercent = CInt(rdr("DiscountPercent"))
Line 246: _Type = rdr("Type").ToString
Line 247: _TypeMk = rdr("TypeMk").ToString

Source File: G:\WebVB\App_Code\Objects\Product.vb Line: 246
Stack Trace:

[IndexOutOfRangeException: Type]
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +95
System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +170
System.Data.SqlClient.SqlDataReader.get_Item(String name) +35
Product.Load(IDataReader rdr) in G:\WebVB\App_Code\Objects\Product.vb:246
admin_products.LoadEditor(Int32 productID) in G:\WebVB\Admin\admin_products.aspx.vb:56
admin_products.Page_Load(Object sender, EventArgs e) in G:\WebVB\Admin\admin_products.aspx.vb:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3036

What i have to do to add Type column in CMRC_Products tabe in COmmerceDB. I'm using ASP.NET 2.0 PayPal-enabled Commerce Starter Kit
 
Last edited by a moderator:
If you add data column there should be something like this

Asuming dt as my datatable

col as new DataColumn("some_column_name")

dt.Columns.Add(col)
 
You need to run a DDL command to add the Column in physical database.
"ALTER TABLE [theTable] ADD COLUMN [colName] [TYPE](SIZE)"

This is done to match the datatable that you create in runtime.
 
Back
Top