473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Update Multiple Posts At same time

Hello there i wonder how the update string should look if i want to update multiple posts at same time.

Iam looping out all post from a table like this:
Expand|Select|Wrap|Line Numbers
  1.     set recsettraktamente = objconn.execute("select * from lander_belopp")
  2.  
  3.     if recsettraktamente.eof then
  4.     response.write "Finns inga traktament belopp angivna"
  5.  
  6.     else
  7.  
  8.     response.write "<form action=""?do=spara_traktamente"" method=""post"">"
  9.  
  10.     do until recsettraktamente.eof
  11.     response.write ""&recsettraktamente("land")&" <input type=""text"" size=""5"" name=""belopp"" value="""&recsettraktamente("belopp")&""">"
  12.  
  13.     bytrad = bytrad+1
  14.     if bytrad = 1 then
  15.     response.write "<br/>"
  16.     bytrad = 0
  17.     end if
  18.  
  19.     recsettraktamente.movenext
  20.     loop
  21.     response.write "<div style=""float:right""><input type=""submit"" value=""Spara Ändringar""></div>"
  22.     response.write "</form>"
  23.     recsettraktamente.close : Set recsettraktamente = Nothing
  24. end if
  25.  
Havent written the Update string because i dont know how i should look like. i tried whit something like this before, but get "index out of range"

Expand|Select|Wrap|Line Numbers
  1. dim i
  2. if request.querystring("do") = "spara_traktamente" then
  3.   for i = 0 to request.form("belopp").count
  4.   objconn.execute("update lander_belopp set belopp='" & request.form("belopp")(i) & "'")
  5.   next
  6. end if
  7.  
Sep 8 '07 #1
10 1572
Anyone that can help me whit this. maybe a simple awnser but whould be nice whit help =)
Sep 8 '07 #2
markrawlingson
346 Expert 100+
What are you trying to do? Are you trying to insert multiple records into a single table - or are you trying to insert 1 record into a single table, but are updating numerous columns within that table?

Judging by the code below it looks like you're trying to insert multiple records and are simply updating 1 column..

dim i
if request.querystring("do") = "spara_traktamente" then
for i = 0 to request.form("belopp").count
objconn.execute("update lander_belopp set belopp='" & request.form("belopp")(i) & "'")
next
end if
If that's the case, you could try this..

Expand|Select|Wrap|Line Numbers
  1. If Request.QueryString("do") = "spara_traktamente" Then
  2.   For Each oItem In Request.Form
  3.      If oItem = "belopp" Then
  4.         objconn.execute("update lander_belopp set belopp='" & request.form(oItem) & "')"
  5.      End If
  6.   Next
  7. End If
  8.  
This will basically Loop through the entire Request.Form object, and if the information is coming from a field called "belopp" it will insert a new record into your table.
Sep 8 '07 #3
The code you postet is what i want to do but dont work. i changed it a bit but get this

Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

Here is the modifyed:
Expand|Select|Wrap|Line Numbers
  1. If Request.QueryString("do") = "spara_traktamente" Then
  2. For Each oItem In Request.Form
  3. If oItem = "belopp" Then
  4.  
  5. objconn.execute("update lander_belopp set belopp='" & request.form(oitem) & "'")&""
  6. End If
  7. Next
  8. End If
  9.  
Sep 9 '07 #4
Dont get it to work, i get Syntax error in UPDATE statement.
Sep 11 '07 #5
Now i have tried to get this to work but i wont. Whats the problem exactly, can someone give me a hint. I know what the error says but how i turn and twist this it wont work. so should be great whit some more help.
Sep 17 '07 #6
markrawlingson
346 Expert 100+
Well,

Any information coming back from the request.form object is automatically a string type. So what data type is your belopp field? It's not a string, and you're trying to throw a strong type variable into it.. it'll throw an error, so you'll have to treat the request.form(oItem) object first to change it from a string value to the context which you need it to be.

The other thing I noticed is at the end of your execute statment you have a couple of double quotes handing around...

Expand|Select|Wrap|Line Numbers
  1. objconn.execute("update lander_belopp set belopp='" & request.form(oitem) & "'")&""
  2.  
You don't need the &"" there after the ) ending the execute statement, not sure why you put them there for?

Sincerely,
Mark
Sep 17 '07 #7
The ending on the code did get wrong, i saw it when i had posted it so the extra dose not exist.

The datatype for the colum belopp is Number. and the value its suppose to put in is a number. =).

The code looks like this now.
Expand|Select|Wrap|Line Numbers
  1.       If Request.QueryString("do") = "spara_traktamente" Then
  2.       For Each oItem In Request.Form
  3.       If oItem = "belopp" Then
  4.  
  5.       objconn.execute("update lander_belopp set belopp=" &    request.form("oItem") & "")
  6.         End If
  7.         Next
  8.        End If
  9.  
Sep 17 '07 #8
markrawlingson
346 Expert 100+
Yeah I figured as much, that's why you're getting the error. Anything that comes back from the Request.Form object will be returned as string data type. I guess I should have mentioned that before - my bad!

You could use CInt wrapped around the data to convert it to a number, but my collegue and I wrote a more sophisticated version of string to numerical conversion as shared with you below. The VAL() function will convert a string to a numerical value, keeps decimal values, will return 0 if the string it's searching does not contain a numerical value, or will entirely rip out any text within the string, returning just the numerical value if one exists. I would use this.. very straight forward and no further work involved.

Expand|Select|Wrap|Line Numbers
  1.   Function Val( sValuePrivate )
  2.     Set oRegExp = New RegExp
  3.     oRegExp.Pattern = "[^0123456789\.]"
  4.     oRegExp.IgnoreCase = True
  5.     oRegExp.Global = True
  6.     Val = Abs( oRegExp.Replace( "0" & sValuePrivate, "" ) )
  7.     Set oRegExp = Nothing
  8.   End Function
  9.  
Example:

Val("Hello my name is 123") - returns 123
Val("Hello my name is Mark") - returns 0
Val("12345") - returns 12345
Val("") - returns 0 (good way to check null/empty values)

Hope this helps
Sincerely,
Mark
Sep 17 '07 #9
Really good man. Thumbs up, but how do i use the function whit the code?
Sep 17 '07 #10
Should i just replace "oitem" whit "oRegExp" ? The thing is the only thing that you type in in the textbox is a number so dont follow why i should have a function thats just take the numbers in the textbox, thats the only thing you will be writing.
Sep 17 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
3
by: -Michelle- | last post by:
Hi Using A2003 on XP I am wondering from the MVP's and others, what is the most efficient way (in terms of time to process) of updating data in a table, using the docmd.RunSQL or Recordset ...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
3
by: sara | last post by:
I've been reading all the posts on this topic. Most are years old, so I have 2 questions: 1. Is there any improvement on opening the same report multiple times (with different input parameters...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
1
by: Max2006 | last post by:
Hi, I am truing to find a pattern for my Business Logic Layer to be able to work fine win ObjectDataSource's Update method. The challenge is ObjectDataSource is not able to work with an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.