p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 (http://p2p.wrox.com/forumdisplay.php?f=264)
-   -   AddEditProduct.aspx (http://p2p.wrox.com/showthread.php?t=68149)

LAM May 15th, 2008 04:15 PM

AddEditProduct.aspx
 
Hi Guys!

I just needed to add couple of fields to the products table. I modified all classes involved in handling products, but problems started to appear as soon as I started to modify the AddEditProduct.aspx page. More precisely, when I modified the DetailsView and the ObjectDataSource.

This is the error that I get, and believe me, before I decided to post this message, I tried everything imaginable!

ObjectDataSource 'objCurrProduct' could not find a non-generic method 'UpdateProduct' that has parameters: ID, DepartmentID, Title, Description, SKU, UnitPrice, DiscountPercentage, UnitsInStock, SmallImageUrl, FullImageUrl, UnitCost.

I browsed the entire web (and beyond) and none of the proposed solutions seem to work. This is driving me nuts! Please help!!


LAM.

Lee Dumond May 15th, 2008 05:05 PM

Your objCurrProduct ObjectDataSource is looking for an UpdateProduct method with a certain signature, and it cannot find one. It derives the necessary signature from the <UpdateParameters>.

Take a look at the <UpdateParamerers> section under your ObjectDataSource. If you changed your UpdateProduct method, you need to change the <UpdateParamters> to match.


LAM May 15th, 2008 07:09 PM


Hi Lee, and thanks for answering so quickly.

I decided to post this message after hours (if not days) of trying all sorts of things. Among those things, are the UpdateProduct method and the <UpdateParameters>. Everything seems to match perfectly, and still I cannot get to the source of the error.

Let me include the parameters list for the <UpdateParameters> as well as the signature of the UpdateProduct method.


<UpdateParameters>
           <asp:Parameter Name="id" Type="Int32" />
           <asp:Parameter Name="departmentID" Type="Int32" />
           <asp:Parameter Name="title" Type="String" />
           <asp:Parameter Name="description" Type="String" />
           <asp:Parameter Name="uniCost" Type="Decimal" />
           <asp:Parameter Name="sku" Type="String" />
           <asp:Parameter Name="unitPrice" Type="Decimal" />
           <asp:Parameter Name="discountPercentage" Type="Int32" />
           <asp:Parameter Name="unitsInStock" Type="Int32" />
           <asp:Parameter Name="smallImageUrl" Type="String" />
           <asp:Parameter Name="fullImageUrl" Type="String" />
       </UpdateParameters>




public static int InsertProduct(int departmentID, string title,
         string description, decimal unitCost, string sku, decimal unitPrice, int discountPercentage,
         int unitsInStock, string smallImageUrl, string fullImageUrl)



I also decided to include the property, just in case someone may be wondering if it was part of the class:

      private decimal _unitCost = 0.0m;
      public decimal UnitCost
      {
          get { return _unitCost; }
          set { _unitCost = value; }
      }


LAM.

Lee Dumond May 15th, 2008 07:24 PM

Are you perhaps confusing Inserting with Updating?

You posted your InsertProduct method. The error, however, deals with the UpdateProduct method, which is something altogether different.


LAM May 15th, 2008 07:28 PM

Quote:

quote:Originally posted by Lee Dumond
 Are you perhaps confusing Inserting with Updating?

You posted your InsertProduct method. The error, however, deals with the UpdateProduct method, which is something altogether different.


Sorry, I posted insert but I meant Update. Here is the one:

public static bool UpdateProduct(int id, int departmentID, string title,
        string description, decimal uniCost, string sku, decimal unitPrice, int discountPercentage,
        int unitsInStock, string smallImageUrl, string fullImageUrl)



LAM.

Lee Dumond May 15th, 2008 09:23 PM

Can you post your whole ObjectDataSource?


LAM May 15th, 2008 09:30 PM

Quote:

quote:Originally posted by Lee Dumond
 Can you post your whole ObjectDataSource?
Yes, I am including it below.

Also I wanted to mention that I already tried setting OldValuesParameterFormatString={0} (in the properties window) and still not working. (Here is why I mentioned this: http://msdn.microsoft.com/en-us/library/bb332381.aspx)

Here is my ObjectDataSource:

<asp:ObjectDataSource ID="objCurrProduct" runat="server" DeleteMethod="DeleteProduct"
   SelectMethod="GetProductByID" TypeName="MB.TheBeerHouse.BLL.Store.Product" InsertMethod="InsertProduct" UpdateMethod="UpdateProduct">
      <DeleteParameters>
         <asp:Parameter Name="id" Type="Int32" />
      </DeleteParameters>
      <SelectParameters>
          <asp:QueryStringParameter Name="productID" QueryStringField="ID" Type="Int32" />
      </SelectParameters>
       <InsertParameters>
           <asp:Parameter Name="departmentID" Type="Int32" />
           <asp:Parameter Name="title" Type="String" />
           <asp:Parameter Name="description" Type="String" />
           <asp:Parameter Name="unitCost" Type="Decimal" />
           <asp:Parameter Name="sku" Type="String" />
           <asp:Parameter Name="unitPrice" Type="Decimal" />
           <asp:Parameter Name="discountPercentage" Type="Int32" />
           <asp:Parameter Name="unitsInStock" Type="Int32" />
           <asp:Parameter Name="smallImageUrl" Type="String" />
           <asp:Parameter Name="fullImageUrl" Type="String" />
       </InsertParameters>
       <UpdateParameters>
           <asp:Parameter Name="id" Type="Int32" />
           <asp:Parameter Name="departmentID" Type="Int32" />
           <asp:Parameter Name="title" Type="String" />
           <asp:Parameter Name="description" Type="String" />
           <asp:Parameter Name="unitCost" Type="Decimal" /> <asp:Parameter Name="sku" Type="String" />
           <asp:Parameter Name="unitPrice" Type="Decimal" />
           <asp:Parameter Name="discountPercentage" Type="Int32" />
           <asp:Parameter Name="unitsInStock" Type="Int32" />
           <asp:Parameter Name="smallImageUrl" Type="String" />
           <asp:Parameter Name="fullImageUrl" Type="String" />

       </UpdateParameters>
   </asp:ObjectDataSource>


Here is the error one more time:

ObjectDataSource 'objCurrProduct' could not find a non-generic method 'UpdateProduct' that has parameters: ID, DepartmentID, Title, Description, UnitCost, SKU, UnitPrice, DiscountPercentage, UnitsInStock, SmallImageUrl, FullImageUrl

LAM.

Lee Dumond May 15th, 2008 09:48 PM

Your UpdateProduct method seems to have uniCost instead of unitCost as a parameter. Could that be it?


LAM May 15th, 2008 09:53 PM

Quote:

quote:Originally posted by Lee Dumond
 Your UpdateProduct method seems to have uniCost instead of unitCost as a parameter. Could that be it?
For a moment I wish that that was the problem, but again, it was an error when copying... I have the correct spelling in my code. I checked line-by-line.

If you take a look at the link that I posted in my previous message, the guy from the tutorial, reproduces the same error and posts the solution. Unfortunately it is not working in my case. I do not know what else to do.

LAM.

LAM May 15th, 2008 10:48 PM

Quote:

quote:Originally posted by Lee Dumond
 Your UpdateProduct method seems to have uniCost instead of unitCost as a parameter. Could that be it?
Apparently the problem is solved. You were right!!! I had uniCost (no "t" in unit) as a parameter in the UpdateProduct method. I was looking at other overload of the same method that had the correct unitCost parameter.

Anyway, shouldn't .net care about the type of the parameter (string, int, etc) and the position (method signature) instead of the actual name of the parameter??

Thanks so much for your help!!! I really appreciate it.

Take care.





LAM.


All times are GMT -4. The time now is 01:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.