Results 1 to 2 of 2

Thread: update database using SQL command?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    update database using SQL command?

    Hi all

    really stuck here. am trying to update a field in a row in my database from within a procedure. have a connection to the database (OleDBConnection1). Trying to run an Update statement that will update the table "ITEMS" column "Quantity" with a WHERE clause based on "ItemID"

    something like this

    UPDATE ITEMS SET Quantity = Quantity - intSoldQty ' from txtbox
    WHERE ItemID = xxx 'this is also from a txtbox

    no matter which approach I take I seem to come unstuck. I think the approach I would need to take is to create a SQL command and run it from the procedure but don't really know how to go about this, and can't seem to find anything useful on the internet. I can post my existing code and database if that would be useful...but if anybody could give me some generic code for creating a SQL command that will run straight onto a database I would really appreciate it

    thanks in advance

    cameron

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Re: update database using SQL command?

    through trial and error found a solution (lots of error!)...so no need to post reply

    cheers

    cameron

    Sub updateQuantity()

    Dim cmd As OleDb.OleDbCommand
    cmd = OleDbConnection1.CreateCommand()
    cmd.CommandText = "UPDATE ITEMS SET QUANTITY = 0;" 'going to insert text box values here

    OleDbConnection1.Open()

    cmd.ExecuteNonQuery()



    End Sub

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