Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Unable to cast object of type Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.IConvertible'
Previous
 
Next
New Post
9/24/2007 3:07 PM
 

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,

{

 

 

}

 
New Post
9/26/2007 8:51 AM
 

It took a while for this post to get authorized so i ended up writing another post with a solution.

it can be found here http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/171344/scope/posts/Default.aspx#171344

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Unable to cast object of type Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.IConvertible'


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out