Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 January 14th, 2004, 05:34 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default ADO Command Update

I'm using the ADO Command object to update records. Using the below example, everything updates fine.

objCommand.CommandText = "UPDATE subs SET department = '" & _
                         strDepart1 & "' WHERE department = '" & _
                         strDepart & "'"

However, if I try to update multiples such as:

objCommand.CommandText = "UPDATE subs SET department = '" & _
                         strDepart1 & "' AND empl = '" & _
                         employee1 & "' WHERE department = '" & _
                         strDepart & "'"

It places empty data in the DB. Can anyone tell me why this is? Am I doing something wrong in my update statement?

Once again, any help would be greatly appreciated.

Chris
 
Old January 14th, 2004, 06:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

For an UPDATE statement, you shouldn't use AND, except for in the WHERE clause.

Here's the general UPDATE syntax:

UPDATE MyTable SET
  MyFirstTextColumn = 'MyValue',
  MySecondTextColumn = 'MyOtherValue',
  MyFirstNumberColumn = 3
WHERE bla bla.

I don't understand why this isn't throwing an error, though....

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 14th, 2004, 06:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Thanks Imar!

No error message was received at all. Just that it deleted data from the first field that I know was there, and did not any other fields specified.

Thanks again!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Update command yogeshyl Oracle 0 November 28th, 2007 08:05 AM
Asynchronous Command Execution in ADO.NET 2.0 suresh_ala Visual Studio 2005 1 February 8th, 2007 10:31 AM





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