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 April 11th, 2006, 11:10 AM
Authorized User
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts
Default Case Select Statements & Updating the Database

I have a Case Select Statement that is selecting what item price goes with what item. (Long and complicated, but this is what I need to do.)

I want to use the result from that Case Select to update the database with the price.

Here's the Case Statement
'--Logo Price based on LogoOption

Dim mySqlConn8 as SqlConnection
Dim mySqlCmd8 as SqlCommand
Dim LogoID as Integer
Dim LogoPrice as String

mySqlConn8 = new SqlConnection("DNS")
    mySqlCmd8 = new SqlCommand("SELECT LogoPrice FROM Logo", mySqlConn8)

    Select Case(LogoPrice)
        Case LogoID = 1
            LogoPrice = "4.25"
        Case LogoID = 2
            LogoPrice = "4.25"
        Case LogoID = 3
            LogoPrice = "1.10"
        Case LogoID = 4
            LogoPrice = "1.10"
        Case LogoID = 5
            LogoPrice = "0.00"
    End Select
And here is the update statements I'm using.

UpdateCMD.Parameters.Add("@LogoPrice", SqlDbType.Money, 8).Value = LogoPrice.Text
How do I get the result from the Case Statement to my Update Statement? I know its syntax, and I have tons of problems with syntax. I also know I probably didn't put the right code blocks here for you to look at. Just let me know what you need.


Old April 11th, 2006, 11:47 AM
Authorized User
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts

Thought I'd forward the error message I get with the above setup.

System.FormatException: Input string was not in a correct format.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior 
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at 
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at 
ASP.OrderPage_aspx.AddToCart(Object s, EventArgs e) in 
D:\Inetpub\Intranet\Apparel\OrderPage.aspx:line 269
With Line 269 being the Update Statement.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating database & saving it to another file OnceANewbie VB Databases Basics 1 December 1st, 2008 06:58 AM
Switch Case statements ermy78 Access VBA 3 October 20th, 2006 08:58 AM
CASE Statements in T-SQL atcs2152 SQL Server 2000 3 April 28th, 2006 10:53 AM
Case Statements cfriedberg SQL Server 2000 1 September 7th, 2005 08:46 PM
Case Statements in Access dbegg Access 2 September 17th, 2003 04:30 PM

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