split array twice and do a multiple insert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • clayalphonso@yahoo.com

    split array twice and do a multiple insert

    Here is the code:

    <%
    dim testArray, testArray2
    dim Conn, rs
    dim sSQL, sConnString
    'response.write request.form("s el1")
    'testArray = split(request.f orm("sel1"),"," )
    'for each gidstuff In testArray
    'Response.Write gidstuff & "<br />"
    'next
    'define the connection string, specify database
    sConnString="wh atever_it_is"
    'create an ADO connection and recordset
    Set Conn = Server.CreateOb ject("ADODB.Con nection")
    Set rs = Server.CreateOb ject("ADODB.Rec ordset")
    'Open the conn
    Conn.Open sConnString
    testArray = split(request.f orm("sel1"),"," )
    For i = lbound(testArra y) to ubound(testArra y)
    'second split
    aSplitArray = split(testArray (i),"$")
    'response.write "GID:" & aSplitArray(0) &" STOREID:" & aSplitArray(1) &
    "<br>"
    sSQL="insert into group_editor_lo g (storeid, oldgid, newgid, stamp,
    eventid, valid) select '" & _
    aSplitArray(1) & "', '" & aSplitArray(0) & "', '" & 1 & "', '" & date()
    & "', '" & 1 & "', '" & 1 & "'"
    response.write sSQL & "<br>"
    Conn.execute(sS QL)
    Next
    response.end()
    'sSQL="insert into group_editor_lo g (storeid, oldgid, newgid, stamp,
    eventid, valid) select '" & _
    'aSplitArray(1) & "', '" & aSplitArray(0) & "', '" & 1 & "', '" &
    date() & "', '" & 1 & "', '" & 1 & "'"
    %>

    I am grabbing multiple select list items and splitting them twice,
    reason for this is that I am carrying over 2 values from the select
    list.

    My problem is this when I am doing a multiple insert the records are
    duplicated, in other words, if I select 3 it inserts 6 six, I can't
    figure out how to insert the exact amount of records that are selected.

    Please help!

  • Alan M

    #2
    Re: split array twice and do a multiple insert


    <clayalphonso@y ahoo.comwrote in message
    news:1166642871 .945873.119120@ 80g2000cwy.goog legroups.com...
    Here is the code:
    >
    <%
    dim testArray, testArray2
    dim Conn, rs
    dim sSQL, sConnString
    'response.write request.form("s el1")
    'testArray = split(request.f orm("sel1"),"," )
    'for each gidstuff In testArray
    'Response.Write gidstuff & "<br />"
    'next
    'define the connection string, specify database
    sConnString="wh atever_it_is"
    'create an ADO connection and recordset
    Set Conn = Server.CreateOb ject("ADODB.Con nection")
    Set rs = Server.CreateOb ject("ADODB.Rec ordset")
    'Open the conn
    Conn.Open sConnString
    testArray = split(request.f orm("sel1"),"," )
    For i = lbound(testArra y) to ubound(testArra y)

    since you have one insert for each item in your array, you must have 6 items
    not 3 in your array

    write it to screen and see

    'second split
    aSplitArray = split(testArray (i),"$")
    'response.write "GID:" & aSplitArray(0) &" STOREID:" & aSplitArray(1) &
    "<br>"
    sSQL="insert into group_editor_lo g (storeid, oldgid, newgid, stamp,
    eventid, valid) select '" & _
    aSplitArray(1) & "', '" & aSplitArray(0) & "', '" & 1 & "', '" & date()
    & "', '" & 1 & "', '" & 1 & "'"
    response.write sSQL & "<br>"
    Conn.execute(sS QL)
    Next
    response.end()

    Why is the insert repeated here?


    'sSQL="insert into group_editor_lo g (storeid, oldgid, newgid, stamp,
    eventid, valid) select '" & _
    'aSplitArray(1) & "', '" & aSplitArray(0) & "', '" & 1 & "', '" &
    date() & "', '" & 1 & "', '" & 1 & "'"
    %>
    >
    I am grabbing multiple select list items and splitting them twice,
    reason for this is that I am carrying over 2 values from the select
    list.
    >
    My problem is this when I am doing a multiple insert the records are
    duplicated, in other words, if I select 3 it inserts 6 six, I can't
    figure out how to insert the exact amount of records that are selected.
    >
    Please help!
    >

    Comment

    Working...