 | 
September 5th, 2008, 03:03 PM
| | Member | | Join Date: Apr 2008
Posts: 66
| | Split value and insert into query
Hi all.
I have problem with this asp code: - strSplitDati = Split(request.Form("dati"), ",")
-
-
for i = LBound(strSplitDati) to (INT(UBound(strSplitDati)/4)-1)*4 step 4
-
-
-
strSql = " INSERT INTO "
-
strSql = strSql & " tbl "
-
strSql = strSql & " ( "
-
strSql = strSql & " ID_UEV, "
-
strSql = strSql & " UEV, "
-
strSql = strSql & " testo_A, "
-
strSql = strSql & " testo_B, "
-
strSql = strSql & " numero_A, "
-
strSql = strSql & " numero_B "
-
strSql = strSql & " ) "
-
strSql = strSql & " VALUES "
-
strSql = strSql & " ( "
-
strSql = strSql & " " & replace(strUEV(0), "'", "''") & ", "
-
strSql = strSql & " '" & replace(strUEV(1), "'", "''") & "', "
-
-
-
if Trim(strSplitDati(i) & "[]") <> "[]" AND Trim(strSplitDati(i+1) & "[]") <> "[]" AND _
-
Trim(strSplitDati(i+2) & "[]") <> "[]" AND Trim(strSplitDati(i+3) & "[]") <> "[]" _
-
then
-
strSql = strSql & ",'" & strSplitDati(i) & "' "
-
strSql = strSql & ",'" & strSplitDati(i+1) & "' "
-
strSql = strSql & "," & strSplitDati(i+2) & " "
-
strSql = strSql & "," & strSplitDati(i+3) & " "
-
-
else
-
-
strSql = strSql & ", '-' "
-
strSql = strSql & ", '-' "
-
strSql = strSql & ", -1 "
-
strSql = strSql & ", -1 "
-
-
end if
-
-
strSql = strSql & " ) "
-
cn.execute strSql
-
-
response.write strSQL & "<br /><br />"
-
-
next
this code write this : Quote:
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 ???? Quote:
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 )
| | 
September 7th, 2008, 09:32 AM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah Age: 32
Posts: 2,363
| |
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 - 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
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |