Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2009, 01:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Yeah, you are close.. but you were lucky.

You are executing a scalar on a query that returns multiple records, and the first value of the first record is always Itemprice.

that's your problem..
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 8th, 2009, 01:13 PM
Authorized User
 
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I have scoured the books I have, and hit every site online that even vaguely mentions anything close to my calculations. I have something working, what I want to know is if I have some hidden problem that I might not see. I don't want this thing mis-adding for some weird combination.

I got mixed results on the ExecuteScalar, and ended up going with straight calculations since my Tax, SubTotal and GrandTotal needed the ItemPrice and the LogoPrice to do their thing. ExecuteScalar tended to count my lines of items, which is ok, unless someone orders 2 of the same item, then it only counted it as 1.

Code:
Function GetItemTotal(extension as string) As Decimal
 Dim objConn As SqlConnection
 Dim objCmd As SqlCommand
 Dim lblTotal As String
 Dim decRunningTotal As Decimal = 0
 Dim objRdr As SqlDataReader
 Dim itemQu as integer  = 0
 
 objConn = new SqlConnection("server=(); User ID=();Password=();database=();connect timeout=30")
 objCmd = new SqlCommand("SELECT ItemPrice, LogoPrice, ItemQuantity FROM Order WHERE Extension = '" & Extension & "'", objConn)
 objConn.Open()
 objRdr = objCmd.ExecuteReader()
 While objRdr.Read
  decRunningTotal += FormatCurrency(((objRdr.Item("ItemPrice") + objRdr.Item("LogoPrice")) * objRdr.Item("ItemQuantity")),2)
  itemQu += Cint(ObjRdr.item("ItemQuantity"))
 End While
 
 taxlbl.text = FormatCurrency((decRunningTotal * .07),2)
 
 Dim QoItems as Integer
 
 QoItems = itemQu
  if QoItems <4 then
      shiplbl.text = FormatCurrency(("1"),2)
  elseif QoItems >5 then
      shiplbl.text = FormatCurrency(("3"),2)
  else
      shiplbl.text = FormatCurrency(("2"),2)
  end if
 
 GrandTotallbl.text = FormatCurrency((decRunningTotal + taxlbl.text + shiplbl.text),2)
 Return decRunningTotal
 
 objConn.Close()
End Function





Similar Threads
Thread Thread Starter Forum Replies Last Post
error in shoppingcartbox (shopping cart in right ) gujju BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 December 12th, 2007 08:47 PM
Shopping Cart Error wdarnellg BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 October 23rd, 2007 11:04 AM
Shopping Cart seannie ASP.NET 2.0 Basics 0 December 12th, 2006 10:28 AM
http_client.php shopping cart error boetheus Beginning PHP 0 November 21st, 2004 11:22 AM
C# shopping cart franknguyen ASP.NET 1.x and 2.0 Application Design 1 January 5th, 2004 10:54 AM





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