Ask a Question related to ASP, Design and Development.

  1. #1

    Default Some help plz

    Ok , here's the deal , ive got a DB where there is a table called products
    wich as the "ID", "description" , "Stock" fields in it , i have another one
    in wich i have "ID" , "Counted".
    What i need to do is to somehow retreive all the data from table 1 into a
    form with a texbox where users will put the quantity they count for each of
    the ids , after completion it will be sent to the other table.

    My form should look like this :

    ID Description Counted
    ------------------------------------
    001 Product 1 _______
    002 Product 2 _______
    003 Product 3 _______
    ...... .............. ..............
    099 Product 99 _______
    ------------------------------------

    "Submit Inventory"

    I need all the products in the same form , how can i do this? If i only
    display one product at a time i have no prob , but with multiple values i
    dont know how! Plz help me!!!!



    Thanks



    Nuno Caldas Guest

  2. #2

    Default Re: Some help plz

    Alright, good deal.


    <form method=post action=SaveCount.asp>

    <%
    Dim sSQL
    Dim RS
    Dim CN
    Dim sConnectionString

    sConnectionString="Something Appropriate as found at
    [url]www.connectionstrings.com[/url] "
    sSQL="SELECT [ID], [Description] FROM [products] ORDER BY [ID]"

    Set CN=CreateObject("ADODB.Connection")
    CN.Open sConnectionString

    Set RS=CN.Execute(sSQL)
    if not RS.EOF then
    Response.write "<table
    border=1><tr><th>ID</th><th>Description</th><th>Counted</th></tr>" & vbCrlf

    Do While not RS.EOF
    Response.write "<tr><td>" & _
    RS.Fields("ID") & _
    "</td><td>" & _
    RS.Fields("Description") &_
    "</td><td>" & _
    "<input name=Product" & RS.Fields("ID") & " >" & _
    "</td></tr>" & vbCrLf

    RS.MoveNext
    Loop
    Response.write "</table>"
    end if
    Set RS=nothing

    CN.Close
    Set CN=nothing
    %>
    </form>


    SaveCount.asp contains....
    <%
    Dim sSQL
    Dim RS
    Dim CN
    Dim sConnectionString
    Dim iCount

    sConnectionString="Something Appropriate as found at
    [url]www.connectionstrings.com[/url] "
    sSQL="SELECT [ID] FROM [products]"

    Set CN=CreateObject("ADODB.Connection")
    CN.Open sConnectionString

    Set RS=CN.Execute(sSQL)
    if not RS.EOF then
    Do While not RS.EOF
    iCount=Request.Form("Product" & RS.Fields("ID"))
    if isNumeric(iCount) and (iCount <> "") then
    sSQL="UPDATE [products] set [Counted]=" & iCount & " WHERE
    [ID]=" & RS.Fields("ID")
    Response.write "<li>" & sSQL & "</li>"
    CN.Execute sSQL
    else
    Response.write "<li><b>Did not update ID: " &
    RS.Fields("ID") & "</b></li>"
    end if
    RS.MoveNext
    Loop
    Response.write "All done......"
    end if
    Set RS=nothing
    CN.CLose
    Set CN=nothing
    %>



    "Nuno Caldas" <nunocaldas@iol.pt> wrote in message
    news:3f980438$0$1914$a729d347@news.telepac.pt...
    > Ok , here's the deal , ive got a DB where there is a table called products
    > wich as the "ID", "description" , "Stock" fields in it , i have another
    one
    > in wich i have "ID" , "Counted".
    > What i need to do is to somehow retreive all the data from table 1 into a
    > form with a texbox where users will put the quantity they count for each
    of
    > the ids , after completion it will be sent to the other table.
    >
    > My form should look like this :
    >
    > ID Description Counted
    > ------------------------------------
    > 001 Product 1 _______
    > 002 Product 2 _______
    > 003 Product 3 _______
    > ..... .............. ..............
    > 099 Product 99 _______
    > ------------------------------------
    >
    > "Submit Inventory"
    >
    > I need all the products in the same form , how can i do this? If i only
    > display one product at a time i have no prob , but with multiple values i
    > dont know how! Plz help me!!!!
    >
    >
    >
    > Thanks
    >
    >
    >

    Tom B Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139