Results 1 to 4 of 4

Thread: [RESOLVED] Query Help

  1. #1

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Resolved [RESOLVED] Query Help

    Hey there

    to start of with my sql is pretty poor when attempting complicated queries
    so i was wondering how to do the following

    l_sqlStmt = "UPDATE stocktakeitem SET "
    l_sqlStmt &= "qty = qty + " & p_sti.Qty & " "
    l_sqlStmt &= "WHERE stiid = " & p_sti.StockTakeItemID

    its the bold part im trying to work out i want to update the qty that exists by adding the old qty and new qty together.

    im sure its a subquery thats involved here
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Query Help

    If p_sti.Qty and p_sti.StockTakeItemID both return a number (in VB) , then it should be ok.

    If it doesn't work, show us the full SQL statement (using: Debug.Print l_sqlStmt ), and tell us what the problem is.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Query Help

    That looks about fine at first glance at least. Try enclosing the addition in parantheses.

    What is the problem though?

  4. #4

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Query Help

    cant believe thats works.... but the reason it didnt for me was i left something obvious out of the where clause... cheers for the help
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width