Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 February 14th, 2004, 12:54 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update multiple fields.


I have the need for updating multiple fields in a record.
The table name is kontingent. My sql statement look like this.

MySql = "UPDATE Kontingent SET(Jan, Feb, Mar, Apr, Maj, Jun, Jul, Aug, Sep, Okt, Nov, Dec) = (2,2,1,1,1,1,1,2,2,2,2,2) WHERE MemID =18"

I am updating another table before this one and it works fine,

but when I excecute the statement.
set objRS = objDC.Execute(MySql)

I get the page is not available. Can anyone see what is wrong in my sql string. Thanks in advance.



 
Old February 14th, 2004, 01:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

You need to pass the values 'one by one', like this:

UPDATE Kontingent SET Jan = 2, Feb = 2, Mar = 1 ...

Håber det hjælper...

 
Old February 14th, 2004, 01:26 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jonax
Thank for your reply
I was afraid that this might be the problem, but others tell me that the following syntaks should be possible.
"
It is also possible to UPDATE multiple columns at the same time. The syntax in this case would look like the following:

UPDATE TABLE "table_name"
SET ("column_1", "column_2") = ([new value 1], [new value 2])
WHERE {condition}
"
Ha en forsat god dag.


 
Old February 14th, 2004, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Hi again,

I have never seen that syntax used - have a look here: http://www.mysql.com/doc/en/UPDATE.html

 
Old February 14th, 2004, 03:22 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jonax

Your link basicly shows your first idea. My logical sence tell me that it can't be true that one have to send multiple commands to update one record. My first suggestion came from here. http://www.1keydata.com/sql/sqlupdate.html
They can of course be wrong, but it make sence.
Cheers
Karsten


 
Old February 14th, 2004, 03:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

I shan't say they're wrong - but as previously mentioned - it's not a syntax that I reckognize. The syntax I'm suggesting doesn't mean that you have to send multiple commands - you can update many fields using one statement...

UPDATE Kontingent SET Jan = 2, Feb = 2, Mar = 1 WHERE MemID = 18

By the way - what database are you using, and are all of your fields of type INT?


 
Old February 15th, 2004, 10:26 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jonax
I got it working after some rewriting of my VB. Thanks for your help.
Cheers.







Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple columns in an update statement debbiecoates SQL Server 2000 1 August 17th, 2008 04:01 AM
update a fields value Vince_421 Access VBA 2 May 19th, 2006 06:41 AM
Update Table fields karajian Access VBA 2 December 7th, 2004 03:48 PM
Updating multiple Rows from multiple fields in ASP vdm_nana SQL Server ASP 0 April 1st, 2004 04:26 AM
UPDATE multiple fields in 1 form a_pathak SQL Server ASP 1 March 3rd, 2004 04:19 AM





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