I'm working with a TreeView, A User enters a new category name, and checks off the TreeView checkboxes to associated which of the current categories the new category is to fall under.
Here is the Error i receive.
System.InvalidCastException: Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.IConvertible'.
at System.Convert.ToInt32(Object value)
at ca.platypidesigns.Store.SqlDataProvider.AddCategory(Int32 portalID, String title, Int32 parent) in e:\webshare\webpub\DotNetNuke_4.5.3\App_Code\PD_StoreFront\Providers\SqlDataProvider.cs:line 282
at ca.platypidesigns.Store.CategoryController.AddCategory(CategoryInfo objCategory) in e:\webshare\webpub\DotNetNuke_4.5.3\App_Code\PD_StoreFront\CategoryController.cs:line 76
at ca.platypidesigns.Store.Recursion.AddCategory(TreeNode node, Int32 portalID, String title) in e:\webshare\webpub\DotNetNuke_4.5.3\App_Code\PD_StoreFront\Recursion.cs:line 60
at ca.platypidesigns.Store.DesktopModules_PD_StoreFront_Admin_Categories.btnAddCat_Click(Object sender, EventArgs e) in e:\webshare\webpub\DotNetNuke_4.5.3\DesktopModules\PD_StoreFront\Admin_Categories.ascx.cs:line 50
Here are the related code blocks:
SqlDataProvider lines 280-285:
public
override int AddCategory(int portalID, string title, int parent)return (Convert.ToInt32((SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner + ObjectQualifier +"usp_PDSF_AddCategory", portalID, GetNull(title), GetNull(parent)))));
CategoryController line: 74-78:
{
objCategory.Title, objCategory.ParentCategory)));
}
Recursion lines 48-68:
{
{
{
ci.PortalID = portalID;
ci.ParentCategory =
ci.Title = title;
}
{
AddCategory(child,portalID,title);
}
}
}
Admin_Category lines 33- 62
{
protected void btnAddCat_Click(object sender, EventArgs e)try
{
{
ci.ParentCategory = 0;
ci.PortalID = PortalId;
ci.Title = txtNewCat.Text;
}
LoadTreeView();
}
{
Trace().Write(ex.ToString());
}
TreeNode root = trvCategories.Nodes[0];if (root.Checked)CategoryInfo ci = new CategoryInfo();CategoryController.AddCategory(ci);if (root.ChildNodes.Count > 0)Recursion.AddCategory(root, PortalId, txtNewCat.Text);catch (Exception ex)finally
{
//Response.Redirect(PlatypiConfigurationSection.GetConfig().AdminLandingPage);
}
}
does anyone know why i am getting this error or can give me any guidance. the only hit from google is in a foreign language.
Any help is greatly appretiated.
SyntaxC4
public static void AddCategory(TreeNode node, int portalID, string title)foreach (TreeNode child in node.ChildNodes)if (child.Checked)CategoryInfo ci = new CategoryInfo();Convert.ToInt32(child.Value);CategoryController.AddCategory(ci);if (child.ChildNodes.Count > 0)public static int AddCategory(CategoryInfo objCategory)return ((int)(DataProvider.Instance().AddCategory(objCategory.PortalID,
{
}