0
votes

I have a data coming from array like following :

(AuthName1,AuthAddr1,AuthEmail1~AuthName2,AuthAddr2,AuthEmail2~)

so i split it using the following code:

<%
dim authinfo
dim arr1

arr1 = Split(authinfo,"~")
for each item in arr1
response.write item
response.write ("<br>")
next
%>

It give the following result :

AuthName1,AuthAddr1,AuthEmail1 AuthName2,AuthAddr2,AuthEmail2

then i update the above code as following to split each part :

<%
dim authinfo
dim arr1

arr1 = Split(authinfo,"~")
for each item in arr1


arr2 = split(item,",")
for each item2 in arr2

response.Write item2
response.Write ("<br>")

response.write ("<br>")
next
%>

what i want is insert each item in (arr2) into a database table using sql, that table is (ID, AuthorName, AuthorAddress, AuthorEmail)

1

1 Answers

0
votes
INSERT INTO 
    [dbo].[TestTable1]
        ([F1], [F2], [F3])
VALUES
      (arr2 (0), arr2 (1), arr2 (2))

because "arr2" is array, you could use arr2 (0), arr2 (1), arr2 (2), where arr2 (0) = AuthName1 arr2 (1) = AuthAddr1 arr2 (2) = AuthEmail1

also, please change from

    for each item2 in arr2
        response.Write item2

to

    for each item2 in arr2
        response.Write item2
    next

Finally:

dim authinfo
dim arr1

authinfo = "AuthName1,AuthAddr1,AuthEmail1~AuthName2,AuthAddr2,AuthEmail2"

arr1 = Split(authinfo,"~")

for each item in arr1
    arr2 = split(item,",")

    Response.Write arr2 (0) & ";" & arr2 (1) & ";" & arr2 (2)
    '### Your SQL statement should be there !

next

NOTE! Do not forget to verify array size!