Nearly There ! still stuck on look code

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Nearly There ! still stuck on look code

    I've been following various tutorials from Jules's Website.

    I've now got a page that inserts a new 'retailer' and then puts the UserID
    into a session. On the next page the session is called.

    I have a table named 'Prices' with four fields. ID - USerID - productID -
    Price

    I need to loop through and insert all of the ProductID's from the Products
    Table AND THE Session UserID so that this new retailer has a full list of
    products.

    Can i do this using the MMInsert Server Behaviour?

    Andy



    Andy Guest

  2. Similar Questions and Discussions

    1. stuck
      having trouble intergrating files! ive created some interactive animations in director and I want my flash interfce to link to these html shockwave...
    2. CFC Query - stuck, stuck, stuck
      I am once again trying to use Dreamweaver. Here I want to create my first CFC. I'm following the online tutorial Building Your First Database...
    3. [PHP] Am stuck
      On Thu, 25 Sep 2003 15:09:31 +0200 "Chris Grigor" <aphrodit@iafrica.com> wrote: I don't think you need to determine the length of $name. You...
    4. [PHP] Fw: Am stuck
      On Thu, 25 Sep 2003 15:17:26 +0200 "Chris Grigor" <aphrodit@iafrica.com> wrote: Look up str_pad(). ____ Regards, Andu Novac
    5. stuck with SQL
      If you need to use subqueries, you need to upgrage to MySQL 4.1.x. In 4.0.14 you can restructure your query using a LEFT JOIN on the tables. ...
  3. #2

    Default Re: Nearly There ! still stuck on look code

    Andy

    The standard MM_Insert statement is designed to be used with form values,
    and it will be rather complicated to modify it. The code for an insert
    statement inside of a recordset output is not that complicated. This should
    do the trick for you.

    <%
    'Create a connection to your database
    dim strConn
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\websites\Database\database.mdb"

    'Read in the Products Table
    dim adoCn
    dim adoRs
    dim strSQL
    set adoCn = Server.CreateObject("ADODB.Connection")
    adoCn.Open strConn
    set adoRs = Server.CreateObject("ADODB.Recordset")
    strSQL = "Select ProductID, Price From tblProducts"
    set adoRs = adoCn.Execute(strSQL)
    If not adoRs.EOF then
    sProductID = adoRs("ProductID")
    sPrice = adoRs("Price")

    'Carry out an insert
    strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    session("svUSerID") & "," & sProductID & "," & sPrice & ")"
    adoCn.Execute strSQL
    End If
    adoRs.Close
    set adoRs = nothing
    adoCn.Close
    set adoCn = nothing
    %>

    This assumes that ProductID is a numeric field. If it is a text value then
    the line needs to be like this

    strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    session("svUSerID") & ",'" & sProductID & "'," & sPrice & ")"



    --
    Regards

    Paul Whitham
    Macromedia Certified Professional for Dreamweaver MX2004
    Valleybiz Internet Design
    [url]www.valleybiz.net[/url]

    Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    [url]www.macromedia.com/support/forums/team_macromedia[/url]

    "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    news:d3oj70$b65$1@forums.macromedia.com...
    > I've been following various tutorials from Jules's Website.
    >
    > I've now got a page that inserts a new 'retailer' and then puts the UserID
    > into a session. On the next page the session is called.
    >
    > I have a table named 'Prices' with four fields. ID - USerID - productID -
    > Price
    >
    > I need to loop through and insert all of the ProductID's from the
    Products
    > Table AND THE Session UserID so that this new retailer has a full list of
    > products.
    >
    > Can i do this using the MMInsert Server Behaviour?
    >
    > Andy
    >
    >
    >

    Paul Whitham TMM Guest

  4. #3

    Default Re: Nearly There ! still stuck on look code

    Hi Paul
    Thanks for the help!

    I've only just checked the post. I've been away from the pc for a few days.
    There IS a world out there! :-)

    I'll post back when i've tried your advice out.

    Thanks again
    Andy


    "Paul Whitham TMM" <paul@valleybiz.net> wrote in message
    news:d3ulpb$73m$1@forums.macromedia.com...
    > Andy
    >
    > The standard MM_Insert statement is designed to be used with form values,
    > and it will be rather complicated to modify it. The code for an insert
    > statement inside of a recordset output is not that complicated. This
    should
    > do the trick for you.
    >
    > <%
    > 'Create a connection to your database
    > dim strConn
    > strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\websites\Database\database.mdb"
    >
    > 'Read in the Products Table
    > dim adoCn
    > dim adoRs
    > dim strSQL
    > set adoCn = Server.CreateObject("ADODB.Connection")
    > adoCn.Open strConn
    > set adoRs = Server.CreateObject("ADODB.Recordset")
    > strSQL = "Select ProductID, Price From tblProducts"
    > set adoRs = adoCn.Execute(strSQL)
    > If not adoRs.EOF then
    > sProductID = adoRs("ProductID")
    > sPrice = adoRs("Price")
    >
    > 'Carry out an insert
    > strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    > session("svUSerID") & "," & sProductID & "," & sPrice & ")"
    > adoCn.Execute strSQL
    > End If
    > adoRs.Close
    > set adoRs = nothing
    > adoCn.Close
    > set adoCn = nothing
    > %>
    >
    > This assumes that ProductID is a numeric field. If it is a text value then
    > the line needs to be like this
    >
    > strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    > session("svUSerID") & ",'" & sProductID & "'," & sPrice & ")"
    >
    >
    >
    > --
    > Regards
    >
    > Paul Whitham
    > Macromedia Certified Professional for Dreamweaver MX2004
    > Valleybiz Internet Design
    > [url]www.valleybiz.net[/url]
    >
    > Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    > [url]www.macromedia.com/support/forums/team_macromedia[/url]
    >
    > "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    > news:d3oj70$b65$1@forums.macromedia.com...
    > > I've been following various tutorials from Jules's Website.
    > >
    > > I've now got a page that inserts a new 'retailer' and then puts the
    UserID
    > > into a session. On the next page the session is called.
    > >
    > > I have a table named 'Prices' with four fields. ID - USerID -
    productID -
    > > Price
    > >
    > > I need to loop through and insert all of the ProductID's from the
    > Products
    > > Table AND THE Session UserID so that this new retailer has a full list
    of
    > > products.
    > >
    > > Can i do this using the MMInsert Server Behaviour?
    > >
    > > Andy
    > >
    > >
    > >
    >
    >

    Andy Guest

  5. #4

    Default Re: Nearly There ! still stuck on look code

    Hi Paul

    I'm working through your advice but im getting this error

    Microsoft JET Database Engine (0x80040E0C)
    Command text was not set for the command object.
    /MyWebs/Dynamic Brochure/adm1n/new_retailer_populate.asp, line 16

    Line 16 is: set adoRs=adoCn.Execute(srtSQL)

    Any idea what might be causing this?

    Andy



    "Andy" <andyjhughesSPAMBUSTER@ntlworld.com> wrote in message
    news:d437a6$978$1@forums.macromedia.com...
    > Hi Paul
    > Thanks for the help!
    >
    > I've only just checked the post. I've been away from the pc for a few
    > days.
    > There IS a world out there! :-)
    >
    > I'll post back when i've tried your advice out.
    >
    > Thanks again
    > Andy
    >
    >
    > "Paul Whitham TMM" <paul@valleybiz.net> wrote in message
    > news:d3ulpb$73m$1@forums.macromedia.com...
    >> Andy
    >>
    >> The standard MM_Insert statement is designed to be used with form values,
    >> and it will be rather complicated to modify it. The code for an insert
    >> statement inside of a recordset output is not that complicated. This
    > should
    >> do the trick for you.
    >>
    >> <%
    >> 'Create a connection to your database
    >> dim strConn
    >> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    >> Source=c:\websites\Database\database.mdb"
    >>
    >> 'Read in the Products Table
    >> dim adoCn
    >> dim adoRs
    >> dim strSQL
    >> set adoCn = Server.CreateObject("ADODB.Connection")
    >> adoCn.Open strConn
    >> set adoRs = Server.CreateObject("ADODB.Recordset")
    >> strSQL = "Select ProductID, Price From tblProducts"
    >> set adoRs = adoCn.Execute(strSQL)
    >> If not adoRs.EOF then
    >> sProductID = adoRs("ProductID")
    >> sPrice = adoRs("Price")
    >>
    >> 'Carry out an insert
    >> strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    >> session("svUSerID") & "," & sProductID & "," & sPrice & ")"
    >> adoCn.Execute strSQL
    >> End If
    >> adoRs.Close
    >> set adoRs = nothing
    >> adoCn.Close
    >> set adoCn = nothing
    >> %>
    >>
    >> This assumes that ProductID is a numeric field. If it is a text value
    >> then
    >> the line needs to be like this
    >>
    >> strSQL = "Insert into Prices(USerID,productID,Price) values (" &
    >> session("svUSerID") & ",'" & sProductID & "'," & sPrice & ")"
    >>
    >>
    >>
    >> --
    >> Regards
    >>
    >> Paul Whitham
    >> Macromedia Certified Professional for Dreamweaver MX2004
    >> Valleybiz Internet Design
    >> [url]www.valleybiz.net[/url]
    >>
    >> Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    >> [url]www.macromedia.com/support/forums/team_macromedia[/url]
    >>
    >> "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    >> news:d3oj70$b65$1@forums.macromedia.com...
    >> > I've been following various tutorials from Jules's Website.
    >> >
    >> > I've now got a page that inserts a new 'retailer' and then puts the
    > UserID
    >> > into a session. On the next page the session is called.
    >> >
    >> > I have a table named 'Prices' with four fields. ID - USerID -
    > productID -
    >> > Price
    >> >
    >> > I need to loop through and insert all of the ProductID's from the
    >> Products
    >> > Table AND THE Session UserID so that this new retailer has a full list
    > of
    >> > products.
    >> >
    >> > Can i do this using the MMInsert Server Behaviour?
    >> >
    >> > Andy
    >> >
    >> >
    >> >
    >>
    >>
    >
    >
    >


    Andy 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