Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 August 19th, 2004, 12:52 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default label cant display total value... pls help

Hi,
im trying to display my sum value with a label, but it show me this error. i've no idea bout this...

Exception Details: System.IndexOutOfRangeException: AvaiStockQty

Source Error:

Line 46: ObjReader=ObjCmd1.ExecuteReader
Line 47: While ObjReader.Read()
Line 48: lbl.text=ObjReader.Item("AvaiStockQty")

Here is my code:
StrSQL="Select Sum(AvaiStockQty) FROM StockOnHand Where ItemCode=@b"
                 Dim ObjCmd1 as OledbCommand= New OleDbCommand(StrSQL, Conn)
                 Dim Stock as String
                  ObjParam= Objcmd1.Parameters.Add("@b", OleDbType.VarChar)
                  ObjParam.Direction= ParameterDirection.Input
                  ObjParam.Value=tb1.Text

                  ObjCmd1.Connection.Open()
                  ObjReader=ObjCmd1.ExecuteReader
                  While ObjReader.Read()
                  lbl.text=ObjReader.Item("AvaiStockQty")
                  End While

I'd tried lbl.text=ObjReader.Item(Sum("AvaiStockQty")) etc... but none seems to work. Can any1 pls help on this?

Thanks in advance
Life's Ng

 
Old August 19th, 2004, 11:56 PM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default

Change your Query statement to this

StrSQL="Select Sum(AvaiStockQty) as tot FROM StockOnHand Where ItemCode=@b"

and modify your while statement

While ObjReader.Read()
lbl.text=ObjReader.Item("tot")
End While


-.. -..
 
Old August 20th, 2004, 02:17 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

Yeah, thanks for ur help!

But it show me this error
Exception Details:System.IndexOutOfRangeException: tt
Line 64:lbl.Text=ObjReader.Item("tt")

Anyway, i've solve the problem by ExecuteScalar and convert it to string type

lbl.text = ctype(ObjCmd1.ExecuteScalar, String)

Regards
life's Ng







Similar Threads
Thread Thread Starter Forum Replies Last Post
SubTotal() to display in a label JayLou BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 April 11th, 2007 10:18 AM
Display Label in Arabic shashikumar Visual Studio 2005 1 August 4th, 2006 05:10 AM
PIVOT TABLE Grand Total ... pls help !!!! laky Access VBA 0 June 2nd, 2006 03:47 AM
PIVOT TABLE Grand Total ... pls help !!!! laky Access 0 June 2nd, 2006 02:15 AM
Total Amount display doosti Classic ASP Databases 2 November 14th, 2004 07:25 AM





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