Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2004, 12:54 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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.



Reply With Quote
  #2 (permalink)  
Old February 14th, 2004, 01:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
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...

Reply With Quote
  #3 (permalink)  
Old February 14th, 2004, 01:26 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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.


Reply With Quote
  #4 (permalink)  
Old February 14th, 2004, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
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

Reply With Quote
  #5 (permalink)  
Old February 14th, 2004, 03:22 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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


Reply With Quote
  #6 (permalink)  
Old February 14th, 2004, 03:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
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?


Reply With Quote
  #7 (permalink)  
Old February 15th, 2004, 10:26 AM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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.


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.