Professional Web Applications Themes

Duplicating a product in the database - Macromedia Dreamweaver

Maybe I'm doing this the hard way, and if there is an easier way, please do let me know :) I have a database of products. I want to be able to duplicate a product by clicking on a button. So far, so good. When the duplicate button is clicked, my application runs the duplicate.asp page. This page filters the database using the productID that was passed to it, puts the product information into variables and then runs a stored procedure in my SQL Server 2000 database to insert the data into a new record. At least, thats what is ...

  1. #1

    Default Duplicating a product in the database

    Maybe I'm doing this the hard way, and if there is an easier way, please do
    let me know :)
    I have a database of products.
    I want to be able to duplicate a product by clicking on a button. So far, so
    good.

    When the duplicate button is clicked, my application runs the duplicate.asp
    page.
    This page filters the database using the productID that was passed to it,
    puts the product information into variables and then runs a stored procedure
    in my SQL Server 2000 database to insert the data into a new record.

    At least, thats what is supposed to happen.
    However, part of the record is a 'FullDescription' column which has a
    datatype of Text.
    My Stored procedure doesn't like it, or it might be the web page itself that
    calls the SP - either way, the page chokes and reports the line which
    generates the FullDescription SP variable.

    Can anyone shed some light on this?

    My web page SP calling code:

    set duplicate = Server.CreateObject("ADODB.Command")
    duplicate.ActiveConnection = MM_conn_STRING
    duplicate.CommandText = "dbo.duplicateProduct"
    duplicate.CommandType = 4
    duplicate.CommandTimeout = 0
    duplicate.Prepared = true
    duplicate.Parameters.Append duplicate.CreateParameter("SID", 3,
    1,4,duplicate__SID)
    duplicate.Parameters.Append duplicate.CreateParameter("SSID", 3,
    1,4,duplicate__SSID)
    duplicate.Parameters.Append duplicate.CreateParameter("SSSID", 3,
    1,4,duplicate__SSSID)
    duplicate.Parameters.Append duplicate.CreateParameter("ProductCode", 200,
    1,50,duplicate__ProductCode)
    duplicate.Parameters.Append duplicate.CreateParameter("ProductName", 200,
    1,100,duplicate__ProductName)
    duplicate.Parameters.Append duplicate.CreateParameter("BriefDescription",
    200, 1,250,duplicate__BriefDescription)
    duplicate.Parameters.Append duplicate.CreateParameter("FullDescription",
    200, 1,16,duplicate__FullDescription)
    duplicate.Parameters.Append duplicate.CreateParameter("ImageID", 3,
    1,4,duplicate__ImageID)
    duplicate.Parameters.Append duplicate.CreateParameter("Price", 6,
    1,4,duplicate__Price)
    duplicate.Parameters.Append duplicate.CreateParameter("Featured", 901,
    1,1,duplicate__Featured)
    duplicate.Parameters.Append duplicate.CreateParameter("Special", 901,
    1,1,duplicate__Special)
    duplicate.Execute()

    My SQL Server 2000 SP:

    CREATE PROCEDURE dbo.duplicateProduct(
    SID int,
    SSID int,
    SSSID int,
    ProductCode varchar(50),
    ProductName varchar(100),
    BriefDescription varchar(250),
    FullDescription text,
    ImageID int,
    Price smallmoney,
    Featured bit,
    Special bit)
    AS
    INSERT INTO dbo.tblCatMain (SID, SSID, SSSID, ProductCode, ProductName,
    BriefDescription, FullDescription, ImageID, Price, FeaturedProduct,
    SpecialOffer) VALUES (SID, SSID, SSSID, 'ProductCode', 'ProductName',
    'BriefDescription', 'FullDescription', ImageID, Price, Featured,
    Special)
    GO

    Cheers,
    Rob [url]http://robgt.com/[/url]
    Extensions: [url]http://robgt.com/products/index.asp[/url]
    Tutorials: [url]http://robgt.com/tutorials/index.asp[/url]
    Blog: [url]http://blog.robgt.com/[/url]


    RobGT Guest

  2. #2

    Default Re: Duplicating a product in the database

    Try

    insert into t (f1,f2,f3)
    select f1,f2,f3 where id=id

    Although, I wouldn't want to condone duplicating information :)

    --

    Jules
    [url]http://www.charon.co.uk[/url]

    Charon Cart 3
    [url]http://www.charon.co.uk/charoncart[/url]

    ICQ 51328805



    RobGT wrote:
    > Maybe I'm doing this the hard way, and if there is an easier way,
    > please do let me know :)
    > I have a database of products.
    > I want to be able to duplicate a product by clicking on a button. So
    > far, so good.
    >
    > When the duplicate button is clicked, my application runs the
    > duplicate.asp page.
    > This page filters the database using the productID that was passed to
    > it, puts the product information into variables and then runs a
    > stored procedure in my SQL Server 2000 database to insert the data
    > into a new record.
    >
    > At least, thats what is supposed to happen.
    > However, part of the record is a 'FullDescription' column which has a
    > datatype of Text.
    > My Stored procedure doesn't like it, or it might be the web page
    > itself that calls the SP - either way, the page chokes and reports
    > the line which generates the FullDescription SP variable.
    >
    > Can anyone shed some light on this?
    >
    > My web page SP calling code:
    >
    > set duplicate = Server.CreateObject("ADODB.Command")
    > duplicate.ActiveConnection = MM_conn_STRING
    > duplicate.CommandText = "dbo.duplicateProduct"
    > duplicate.CommandType = 4
    > duplicate.CommandTimeout = 0
    > duplicate.Prepared = true
    > duplicate.Parameters.Append duplicate.CreateParameter("SID", 3,
    > 1,4,duplicate__SID)
    > duplicate.Parameters.Append duplicate.CreateParameter("SSID", 3,
    > 1,4,duplicate__SSID)
    > duplicate.Parameters.Append duplicate.CreateParameter("SSSID", 3,
    > 1,4,duplicate__SSSID)
    > duplicate.Parameters.Append duplicate.CreateParameter("ProductCode",
    > 200, 1,50,duplicate__ProductCode)
    > duplicate.Parameters.Append duplicate.CreateParameter("ProductName",
    > 200, 1,100,duplicate__ProductName)
    > duplicate.Parameters.Append
    > duplicate.CreateParameter("BriefDescription", 200,
    > 1,250,duplicate__BriefDescription)
    > duplicate.Parameters.Append
    > duplicate.CreateParameter("FullDescription", 200,
    > 1,16,duplicate__FullDescription)
    > duplicate.Parameters.Append duplicate.CreateParameter("ImageID", 3,
    > 1,4,duplicate__ImageID)
    > duplicate.Parameters.Append duplicate.CreateParameter("Price", 6,
    > 1,4,duplicate__Price)
    > duplicate.Parameters.Append duplicate.CreateParameter("Featured",
    > 901, 1,1,duplicate__Featured)
    > duplicate.Parameters.Append duplicate.CreateParameter("Special", 901,
    > 1,1,duplicate__Special)
    > duplicate.Execute()
    >
    > My SQL Server 2000 SP:
    >
    > CREATE PROCEDURE dbo.duplicateProduct(
    > SID int,
    > SSID int,
    > SSSID int,
    > ProductCode varchar(50),
    > ProductName varchar(100),
    > BriefDescription varchar(250),
    > FullDescription text,
    > ImageID int,
    > Price smallmoney,
    > Featured bit,
    > Special bit)
    > AS
    > INSERT INTO dbo.tblCatMain (SID, SSID, SSSID, ProductCode,
    > ProductName, BriefDescription, FullDescription, ImageID, Price,
    > FeaturedProduct, SpecialOffer) VALUES (SID, SSID, SSSID,
    > 'ProductCode', 'ProductName', 'BriefDescription',
    > 'FullDescription', ImageID, Price, Featured, Special)
    > GO
    >
    > Cheers,
    > Rob [url]http://robgt.com/[/url]
    > Extensions: [url]http://robgt.com/products/index.asp[/url]
    > Tutorials: [url]http://robgt.com/tutorials/index.asp[/url]
    > Blog: [url]http://blog.robgt.com/[/url]

    Julian Roberts Guest

  3. #3

    Default Re: Duplicating a product in the database

    Jules,
    Will that work, or do I need to specify the VALUES( ... ) part of the SQL
    statement too?

    i.e.

    insert into t (f1,f2,f3) values(select f1,f2,f3 where id=id)

    ?????
    I take it this should all happen in the SP...?
    Cheers,
    Rob [url]http://robgt.com/[/url]
    Extensions: [url]http://robgt.com/products/index.asp[/url]
    Tutorials: [url]http://robgt.com/tutorials/index.asp[/url]
    Blog: [url]http://blog.robgt.com/[/url]


    RobGT Guest

  4. #4

    Default Re: Duplicating a product in the database

    I shoudl just trust you really, shouldn't I :)
    Thanks Jules - got it working with your code!
    Much simpler procedure now too!
    Cheers,
    Rob [url]http://robgt.com/[/url]
    Extensions: [url]http://robgt.com/products/index.asp[/url]
    Tutorials: [url]http://robgt.com/tutorials/index.asp[/url]
    Blog: [url]http://blog.robgt.com/[/url]


    RobGT Guest

  5. #5

    Default Re: Duplicating a product in the database

    Cool :)

    --

    Jules
    [url]http://www.charon.co.uk[/url]

    Charon Cart 3
    [url]http://www.charon.co.uk/charoncart[/url]

    ICQ 51328805



    RobGT wrote:
    > I shoudl just trust you really, shouldn't I :)
    > Thanks Jules - got it working with your code!
    > Much simpler procedure now too!
    > Cheers,
    > Rob [url]http://robgt.com/[/url]
    > Extensions: [url]http://robgt.com/products/index.asp[/url]
    > Tutorials: [url]http://robgt.com/tutorials/index.asp[/url]
    > Blog: [url]http://blog.robgt.com/[/url]

    Julian Roberts Guest

Similar Threads

  1. HELP: Product Database - adding images!
    By mark | r in forum ASP
    Replies: 3
    Last Post: October 9th, 07:13 PM
  2. Duplicating a jpg
    By jose Villalobos in forum Macromedia Flash
    Replies: 4
    Last Post: September 5th, 08:24 AM
  3. Duplicating set of records
    By Glenn Schwandt in forum FileMaker
    Replies: 3
    Last Post: August 13th, 11:11 PM
  4. Password duplicating
    By Colin in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 6th, 12:57 AM
  5. Product activation when you've lost your Product ID sticker
    By larry samuels MS-MVP \(XP Shell/User\) in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 5th, 10:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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