Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Complex Multiple Inserts from numerous Tables

I have a page that displays the content of one table "CardList" a repeat region is used for this process.

I am also collecting the DalearID which is passed through the URL from another page. I then match the DealerID in the "SignUp" table to retreive the Dealer record.

Now, I have a form which colects the users information via Form fields and I want to insert the information into the "DealerCardList" table.
I ask for such things as "Price", "QTY" and "Active"

I want to store the DealerID and Card_ID taken from the 2 other tables into the "DealerCardList".

Here is my current syntax. Keep in mind that I am using 3 different recorsets to retreive the information from the 3 various tables.

------------------------

LOOP INSERT

<%
if request("Submit") <> "" Then
Card_IDarray=split(request("Card_ID"),",")
Activearray=split(request("Active"),",")
Pricearray=split(request("Price"),",")
Avail_Qtyarray=split(request("Avail_Qty"),",")
DealerIDarray=split(request("DealerID"),",")
for i=0 to ubound(Card_IDarray)
if len(trim(Card_IDarray(i))) > 0 then
rs_Cards.addnew
rs_CardNames("Card_ID")=trim(Card_IDarray(i))
rs_Cards("Price")=trim(Pricearray(i))
rs_Cards("Active")=trim(Activearray(i))
rs_Cards("Avail_Qty")=trim(Avail_Qtyarray(i))
rsDealer("DealerID")=trim(DealerIDarray(i))
rs_Cards.update
end if
next
response.redirect "addcards.asp"
end if
%>

-----------------

FORM:

<%
While ((Repeat1__numRows <> 0) AND (NOT rs_CardNames.EOF))
%>



Yes
No


<%=(rs_CardNames.Fields.Item("Card_Name").Value)%>
$







">
">

<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_CardNames.MoveNext()
Wend
%>

-----------------------------

The display of the Form works well, the appropriate values in the hidden fields are correct, yet something goes wrong when it tries to store the information.

Any help would be very much appreciated.






Comments

  • vanithvanith Posts: 44Member

    Hi LiquiDx,

    Ofcourse you may have needed 3 recordsets while displaying the form. But why do you need em all when you are inserting into one single table "DealerCardList".

    If "Card_ID" and "DealerID" fields exist in the "DealerCardList" table, correct your code for insert. look you are trying to update rs_CardNames("Card_ID") and rsDealer("DealerID") when it should be rs_Cards("Card_ID") and rs_Cards("DealerID") respectively.

    ----your code snippet----
    : if len(trim(Card_IDarray(i))) > 0 then
    : rs_Cards.addnew
    : rs_CardNames("Card_ID")=trim(Card_IDarray(i))
    : rs_Cards("Price")=trim(Pricearray(i))
    : rs_Cards("Active")=trim(Activearray(i))
    : rs_Cards("Avail_Qty")=trim(Avail_Qtyarray(i))
    : rsDealer("DealerID")=trim(DealerIDarray(i))
    : rs_Cards.update
    : end if
    --------------------------

    :)heers,
    Vanith

    : I have a page that displays the content of one table "CardList" a repeat region is used for this process.
    :
    : I am also collecting the DalearID which is passed through the URL from another page. I then match the DealerID in the "SignUp" table to retreive the Dealer record.
    :
    : Now, I have a form which colects the users information via Form fields and I want to insert the information into the "DealerCardList" table.
    : I ask for such things as "Price", "QTY" and "Active"
    :
    : I want to store the DealerID and Card_ID taken from the 2 other tables into the "DealerCardList".
    :
    : Here is my current syntax. Keep in mind that I am using 3 different recorsets to retreive the information from the 3 various tables.
    :
    : ------------------------
    :
    : LOOP INSERT
    :
    : <%
    : if request("Submit") <> "" Then
    : Card_IDarray=split(request("Card_ID"),",")
    : Activearray=split(request("Active"),",")
    : Pricearray=split(request("Price"),",")
    : Avail_Qtyarray=split(request("Avail_Qty"),",")
    : DealerIDarray=split(request("DealerID"),",")
    : for i=0 to ubound(Card_IDarray)
    : if len(trim(Card_IDarray(i))) > 0 then
    : rs_Cards.addnew
    : rs_CardNames("Card_ID")=trim(Card_IDarray(i))
    : rs_Cards("Price")=trim(Pricearray(i))
    : rs_Cards("Active")=trim(Activearray(i))
    : rs_Cards("Avail_Qty")=trim(Avail_Qtyarray(i))
    : rsDealer("DealerID")=trim(DealerIDarray(i))
    : rs_Cards.update
    : end if
    : next
    : response.redirect "addcards.asp"
    : end if
    : %>
    :
    : -----------------
    :
    : FORM:
    :
    : <%
    : While ((Repeat1__numRows <> 0) AND (NOT rs_CardNames.EOF))
    : %>
    :
    :
    :
    : Yes
    : No
    :
    :
    : <%=(rs_CardNames.Fields.Item("Card_Name").Value)%>
    : $
    :
    :
    :
    :
    :
    :
    :
    : ">
    : ">
    :
    : <%
    : Repeat1__index=Repeat1__index+1
    : Repeat1__numRows=Repeat1__numRows-1
    : rs_CardNames.MoveNext()
    : Wend
    : %>
    :
    : -----------------------------
    :
    : The display of the Form works well, the appropriate values in the hidden fields are correct, yet something goes wrong when it tries to store the information.
    :
    : Any help would be very much appreciated.
    :
    :
    :
    :
    :
    :
    :

Sign In or Register to comment.