CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.commerce_starter_kit Tags:
Item Type: NewsGroup Date Entered: 9/12/2003 4:15:11 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 14 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
chuke
Asp.Net User
Specified cast is not valid9/12/2003 4:15:11 PM

0/0

I have been working with the CSSDK version of the Commerce kit.

I have made several modifications, and up until now it has worked like a dream...

Afer I add data from SQL Enterprise Manager into the CMRC_Products table I get theis error:

-----------------------------

Server Error in '/fl' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 27: // Obtain Product Details
Line 28: ASPNET.StarterKit.Commerce.ProductsDB products = new ASPNET.StarterKit.Commerce.ProductsDB();
Line 29: ASPNET.StarterKit.Commerce.ProductDetails myProductDetails = products.GetProductDetails(ProductID);
Line 30:
Line 31: // Update Controls with Product Details


Source File: E:\Lhand\clients\frozen_light\site\ProductDetails.aspx Line: 29

Stack Trace:


[InvalidCastException: Specified cast is not valid.]
ASPNET.StarterKit.Commerce.ProductsDB.GetProductDetails(Int32 productID) +966
ASP.ProductDetails_aspx.Page_Load(Object sender, EventArgs e) in E:\Lhand\clients\frozen_light\site\ProductDetails.aspx:29
System.Web.UI.Control.OnLoad(EventArgs e) +55
System.Web.UI.Control.LoadRecursive() +27
System.Web.UI.Page.ProcessRequestMain() +731

-----------------------------

I noticed that it is refereing to the ProductID, which is passed to the QueryString, but I never changed the data type in the DB, it is still an int, and required...

Any ideas?

Thanks

chuke
chuke
Asp.Net User
Re: Specified cast is not valid9/13/2003 3:13:13 PM

0/0

I figured it out...

I removed all of the data from the products tble, then re-imported it...

It seems that if you have (null) in a field (even if the field can have a null value) that it throws the cast error...

Hope this helps someone.
mnswiftone
Asp.Net User
Re: Specified cast is not valid9/21/2003 4:02:07 PM

0/0

I found another way to work with it - test for Null and replace it as you enter values into the productsdetail object.
For example, I added a weight parameter(amongst many others) to my products, and use this line to assign it in GetProductDetails(int ProductID):

myProductDetails.Weight = (result["Weight"]!=System.DBNull.Value)?(int)result["Weight"]:0;

This sets the weight to 0 if there is a null in the database. (I'm using MS Access, should be the same for SQL2000 I think).

Add this comparison to System.DBNull.Value for each possible null field and assign a valid value if found - that will fix any unassigned database fields without changing every entry in the database.

Todd Nelson
araigr
Asp.Net User
Re: Specified cast is not valid2/2/2004 1:51:32 PM

0/0

Thanks SOOO much for posting your experience with the null values. I'm not sure that I would have ever figured that out! Your follow up was very helpful.
Ivonne
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Learning to Program the Object-oriented Way with C# Authors: Vinny Cahill, Donal Lafferty, Pages: 626, Published: 2002
Microsoft .Net Framework 1.1 Class Library Reference Authors: Microsoft Corporation, Pages: 0, Published: 2003
Programming Visual Basic .NET Authors: Jesse Liberty, Dave Grundgeiger, Pages: 541, Published: 2003
Learning Visual Basic .NET Authors: Jesse Liberty, Pages: 303, Published: 2003
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Head First C# Authors: Andrew Stellman, Jennifer Greene, Pages: 738, Published: 2007
Beginning Visual Web Programming in VB .NET: From Novice to Professional Authors: Daniel Cazzulino, Craig Bowes, Victor Garcia Aprea, Mike Clark, James Greenwood, Chris Hart, Pages: 648, Published: 2005
Beginning C# 2008 Databases: From Novice to Professional Authors: Vidya Vrat Agarwal, James Huddleston, Ranga Raghuram, Syed Fahad Gilani, Jacob Hammer Pedersen, Jon Reid, Pages: 482, Published: 2008
.Net Gotchas: 75 Ways to Improve Your C# and VB.NET Programs Authors: Venkat Subramaniam, Pages: 372, Published: 2005
Foundations of F# Authors: Robert Pickering, Pages: 360, Published: 2007

Web:
Specified cast is not valid in asp.net/c# foreach loop | Tech Off ... Bashing my head against this and seeking ideas. I have an ASP.NET page which contains a bunch of checkboxes in a panel. They are standalone checkboxes, not ...
- Specified cast is not valid I get the following error :- "Specified cast is not valid." The following is part of a dbConnection.vb class :- ...
ADO.NET Specified cast is not valid - ASP.NET NET Specified cast is not valid - ASP.NET Community and Forum - Our ASP.NET forum is the place for Q&A-style discussions related to the Microsoft Visual ...
p2p.wrox.com Forums - Specified cast is not valid The MyAccount.aspx page is throwing the error 'Specified cast is not valid' for the line: Dim currentUser As New AccBusiness.User( _ ...
OTN Discussion Forums : Specified cast is not valid ... Thread: Specified cast is not valid. Welcome, Guest ... Registered: 04/19/02. Specified cast is not valid Posted: Apr 16, 2004 2:16 PM ...
System.InvalidCastException: Specified cast is not valid - .NET C# System.InvalidCastException: Specified cast is not valid. Get answers to your questions in our .NET C# forum.
FIX: You receive a "Specified cast is not valid" error message in ... Fixes a problem in BizTalk Server 2004 where you receive a "Specified cast is not valid" error message if you use a rule set in the Rules Composer or if you ...
Specified cast is not valid. -how do I determine which variable is ... I have a function in which variables are passed to it that is generating a Specified cast is not valid However, I have no clue as to determine WHICH ...
Specified cast is not valid - ASP.NET Forums Specified cast is not valid. Last post 03-04-2004 11:16 PM by BlinkTech. 4 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Specified cast is not valid exception I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my columns is a template ...

Videos:
AutoTest: Push-button testing using contracts Google London Test Automation Conference (LTAC) Google Tech Talks September 7th, 2006 Presenter: Andreas Leitner
San Diego Housing Outlook; Downtown Community Plan; Imperial Valley Development The face of downtown San Diego is rapidly changing, and with all the new development, it's sometimes hard to keep up. Now 14 years after the Centre C...




Search This Site:










navigation needs upgrades

copy project deployment fixes

adding custom module to page

aspnetmenu tabstrip - silver?

dnn deployment error...please help

portal name

discussion module showing html code

session state

can masterpage find out which page is loaded in a content place holder

source code and future updates

skin error: server tag not well formed

template in aspx

error messagecs0102

ecommerce module used on http://www.alienwaresystems.com.au/

treeview web control rendering as plain text

evite type module?

userid as a foreign key?

redirect page after logout

dnn2 pa installer problem on remote server

errors during install

issue w/skins and friendly urls in 3.1

treeview onselected node

error

losing references when opening solution from source safe

adding reference to system.web.dll hanging in visual studio 2005

how to implement itextcommunication interface

error in visual studio opening client certificate requesting web app

tab index

simple user control

.net v1.1 sp1 and .net 2.0 beta 2

 
All Times Are GMT