|
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
|
|
|
February 14th, 2004, 12:54 PM
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
February 14th, 2004, 01:05 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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...
|
February 14th, 2004, 01:26 PM
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
February 14th, 2004, 03:06 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi again,
I have never seen that syntax used - have a look here: http://www.mysql.com/doc/en/UPDATE.html
|
February 14th, 2004, 03:22 PM
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
February 14th, 2004, 03:55 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
February 15th, 2004, 10:26 AM
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Jonax
I got it working after some rewriting of my VB. Thanks for your help.
Cheers.
|
|
|