Advertisement

04.20.2008 at 08:11AM PDT, ID: 23337760
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

How do I convert system.data.datatable

Asked by wdarnellg in Visual Studio, Microsoft Visual C#.Net, .Net Editors & IDEs

I am trying to build a products access page using  "Beginning ASP.NET2.0 E-Commerce in C# 2005" I am working with vs2008 and .net 3.5. I have encountered a couple of error messages when compiling the code that says "cannot implicitly convert type 'string' to 'int', and 'cannot implicitly convert type 'system.data.datatable' to 'ProductDetails'".  Can anyone tell from the snippit what might be wrong?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
 
 
/// <summary>
/// Product Catalog Business Tier Component
/// </summary>
public struct ProductDetails
{
    public string Name;
    public string Description;
    public decimal Price;
    public string Image1URL;
    public string Image2URL;
    public bool OnDepatmentPromotion;
    public bool OnCatalogPromotion;
}
public static class CatalogAccess
{
    // Get category details
    public static CategoryDetails GetCategoryDetails(string categoryID)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();
        // set the stored procedure name
        comm.CommandText = "GetCategoryDetails";
        // create a new parameter
        DbParameter param = comm.CreateParameter();
        param.ParameterName = "@CategoryID";
        param.Value = categoryID;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);
        // execute the stored procedure
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
        // wrap retrieved data into a CategoryDetails object
        CategoryDetails details = new CategoryDetails();
        if (table.Rows.Count > 0)
        {
            details.DepartmentID = Int32.Parse(table.Rows[0]["DepartmentID"].ToString());
            details.Name  = table.Rows[0]["Name"].ToString(); //STRING TO INT ERROR HERE
            details.Description = table.Rows[0]["Description"].ToString(); //STRING TO INT ERROR HERE           
        }
        // return department details
        return details;
 
        //retrieve the list of categories in a departmemt
        public static ProductDetails GetCategoriesInDepartment(string departmentID)
        { 
        // get a configured DbCommand object
            DbCommand comm = GenericDataAccess.CreateCommand();
            // set the stored pocedure name
            comm.CommandText = "GetCategoriesInDepartment";
            // create a new parameter
            DbParameter param = comm.CreateParameter();
            param.ParameterName = "@DepartmentID";
            param.Value = departmentID;
            param.DbType = DbType.Int32;
            comm.Parameters.Add(param);
            //execute the stored procedure
            return GenericDataAccess.ExecuteSelectCommand(comm);//SYSTEM.DATA.DATATABLE ERROR IS HERE.           
        }
 
 
    }
 
}
[+][-]04.20.2008 at 08:32AM PDT, ID: 21396400

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.20.2008 at 08:51AM PDT, ID: 21396482

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.20.2008 at 08:56AM PDT, ID: 21396499

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.20.2008 at 08:57AM PDT, ID: 21396502

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.20.2008 at 08:58AM PDT, ID: 21396506

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.20.2008 at 09:02AM PDT, ID: 21396517

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio, Microsoft Visual C#.Net, .Net Editors & IDEs
Sign Up Now!
Solution Provided By: JimBrandley
Participating Experts: 3
Solution Grade: B
 
 
[+][-]04.20.2008 at 09:30AM PDT, ID: 21396619

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628