473,395 Members | 2,437 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,395 software developers and data experts.

Split value and insert into query

Hi all.

I have problem with this asp code:

Expand|Select|Wrap|Line Numbers
  1. strSplitDati = Split(request.Form("dati"), ",")
  2.  
  3.         for i = LBound(strSplitDati) to (INT(UBound(strSplitDati)/4)-1)*4 step 4
  4.  
  5.  
  6. strSql = " INSERT INTO "
  7. strSql = strSql & " tbl "
  8. strSql = strSql & " ( "
  9. strSql = strSql & " ID_UEV, "
  10. strSql = strSql & " UEV, "
  11. strSql = strSql & " testo_A, "
  12. strSql = strSql & " testo_B, "
  13. strSql = strSql & " numero_A, "
  14. strSql = strSql & " numero_B "
  15. strSql = strSql & " ) "
  16. strSql = strSql & "   VALUES "
  17. strSql = strSql & " ( "
  18. strSql = strSql & "   " & replace(strUEV(0), "'", "''") & ", "
  19. strSql = strSql & "  '" & replace(strUEV(1), "'", "''") & "', "
  20.  
  21.  
  22. if Trim(strSplitDati(i) & "[]") <> "[]" AND Trim(strSplitDati(i+1) & "[]") <> "[]" AND _
  23.    Trim(strSplitDati(i+2) & "[]") <> "[]" AND Trim(strSplitDati(i+3) & "[]") <> "[]" _
  24. then
  25.    strSql = strSql & ",'" & strSplitDati(i) & "' "
  26.    strSql = strSql & ",'" & strSplitDati(i+1) & "' "
  27.    strSql = strSql & "," & strSplitDati(i+2) & " "
  28.    strSql = strSql & "," & strSplitDati(i+3) & " "
  29.  
  30. else
  31.  
  32.    strSql = strSql & ", '-' "
  33.    strSql = strSql & ", '-' "
  34.    strSql = strSql & ", -1 "
  35.    strSql = strSql & ", -1 "  
  36.  
  37. end if
  38.  
  39. strSql = strSql & " ) "
  40. cn.execute strSql
  41.  
  42. response.write strSQL & "<br /><br />"
  43.  
  44. next
this code write this :

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', 'CS7' ,'Ins' ,1 ,2 )

INSERT INTO tbl ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', 'CS8' ,'Suf' ,3 ,4 )
and not this: why ????

INSERT INTO tbly ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', '-' , '-' , -1 , -1 )

INSERT INTO tbly ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', 'CS7' ,'Ins' ,1 ,2 )

INSERT INTO tbly ( ID_UEV, UEV, testo_A, testo_B, numero_A, numero_B ) VALUES ( 1, 'TRLM', 'CS8' ,'Suf' ,3 ,4 )
Sep 5 '08 #1
1 1799
jhardman
3,406 Expert 2GB
print out the request.form("dati"). What does it say?

My first impression is that your "for" statement is too complicated. It might be easier to say
Expand|Select|Wrap|Line Numbers
  1. for each i in strsplitdati
(i think that's what you are trying to do, but your statement is so complicated, I'm not sure I follow it.)

Jared
Sep 7 '08 #2

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

Similar topics

8
by: middletree | last post by:
Sorry for starting a new thread, but the original was 24 hours ago, and I am afraid it won't get seen. In the original, Ray advised me to change if len(strPeopleID)>0 then arrPeople =...
9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
0
by: j | last post by:
Hi, Anyone out there with binary search tree experience. Working on a project due tomorrow and really stuck. We need a function that splits a binary tree into a bigger one and smaller one(for a...
5
by: Willem | last post by:
Hello I am quite hopeless and of course a newbe. The situation: Sql2k / query I would like it ot break down the following string: 2004 Inventory:Ex.Plant Farm1:1st Cut:Premium:0094
5
by: bu | last post by:
I have a database field that represents an item description and varying length. I am using the database to import the item description into another program (the other program is ODBC-aware ). The...
1
by: Mark Goldin | last post by:
I am trying to split cells in a table. I am selecting a cell and I want to break into two. There is no "split" command available anywhere. What would you suggest?
0
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL,...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
0
by: =?ISO-8859-15?Q?C=E9dric?= | last post by:
Hi all, I want to import a SQL script (SQLite) executing each queries separately. - I read the SQL file - I split the read string with the separator ";" - I execute each query string query...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.