Stored Procedure inserting the same record twice

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

  1. #1

    Default Stored Procedure inserting the same record twice

    I have created a stored procedure in SQL SERVER 2000 (procedure below) and I
    have used and slightly edited the command behaviour to insert data into a table
    (ASP CODE BELOW). The problem is that it is inserting 2 identicle records with
    different ID's at a time. Why would it be doing the insert twice??

    Thanks for your help...sorry about the repost.






    CREATE PROCEDURE [dbo].[spPreTranInsert]
    (@PreTransactionID [int]=000000 output,
    @GivenName [varchar](50),
    @LastName [varchar](50),
    @Address [varchar](250),
    @City [varchar](50),
    @State [char](10),
    @PostCode [varchar](20),
    @Country [varchar](200),
    @Email [varchar](250))

    AS

    INSERT INTO [dbo].[tbPreTransactions]
    ([GivenName],
    [LastName],
    [Address],
    [City],
    [State],
    [PostCode],
    [Country],
    [Email])

    VALUES
    (@GivenName,
    @LastName,
    @Address,
    @City,
    @State,
    @PostCode,
    @Country,
    @Email)
    GO


    Dim cmdInsert__GivenName
    cmdInsert__GivenName = Session("MemFormGivenName")

    Dim cmdInsert__LastName
    cmdInsert__LastName = Session("MemFormLastName")

    Dim cmdInsert__Address
    cmdInsert__Address = Session("MemFormAddress")

    Dim cmdInsert__City
    cmdInsert__City = Session("MemFormCity")

    Dim cmdInsert__State
    cmdInsert__State = Session("MemFormState")

    Dim cmdInsert__PostCode
    cmdInsert__PostCode = Session("MemFormPostcode")

    Dim cmdInsert__Country
    cmdInsert__Country = Session("MemFormCountry")

    Dim cmdInsert__Email
    cmdInsert__Email = Session("MemFormEmail")

    set cmdInsert = Server.CreateObject("ADODB.Command")
    cmdInsert.ActiveConnection = MM_connDANSW_STRING
    cmdInsert.CommandText = "dbo.spPreTranInsert"
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@RETURN_VALUE", 3, 4)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@PreTransactionID",
    3, 2)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@GivenName", 200,
    1,50,cmdInsert__GivenName)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@LastName", 200,
    1,50,cmdInsert__LastName)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Address", 200,
    1,250,cmdInsert__Address)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@City", 200,
    1,50,cmdInsert__City)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@State", 129,
    1,10,cmdInsert__State)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@PostCode", 200,
    1,50,cmdInsert__PostCode)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Country", 200,
    1,200,cmdInsert__Country)
    cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Email", 200,
    1,250,cmdInsert__Email)
    cmdInsert.CommandType = 4
    cmdInsert.CommandTimeout = 0
    cmdInsert.Prepared = true
    cmdInsert.Execute()

    Shmooter Guest

  2. Similar Questions and Discussions

    1. MS SQL stored procedure
      I am new to MS SQL server and stored procedures. I currently have a query that looks like: select from table where fieldname IN...
    2. stored procedure help
      Hi all! I am in need of writing a few stored procedures. The first one is to create a stored procedure to recover a database from backup and the...
    3. Stored procedure?
      Stored procedure ?? -- Message posted via http://www.dotnetmonster.com
    4. Inserting Full Stops into SQL Server 2000 using ASP and stored procedure
      Hi All, I am attempting to use a standard HTML form to pass a parameter to an ASP stored procedure, which searches a database for customer...
    5. Using stored procedure to return a whole row of data, without using record set?
      I now know that I cannot use client application written in embedded SQL to receive record sets, that only an application using CLI can receive...
  3. #2

    Default Re: Stored Procedure inserting the same record twice

    The command isn't going to insert twice unless it's called twice. My guess
    is your command isn't set to fire only on a form submit, but fires on page
    load. You'll have to fix that. In the absence of your page code, though, I
    can't be of any more help.

    "Shmooter" <webforumsuser@macromedia.com> wrote in message
    news:d76fl8$91g$1@forums.macromedia.com...
    >I have created a stored procedure in SQL SERVER 2000 (procedure below) and
    >I
    > have used and slightly edited the command behaviour to insert data into a
    > table
    > (ASP CODE BELOW). The problem is that it is inserting 2 identicle records
    > with
    > different ID's at a time. Why would it be doing the insert twice??
    >
    > Thanks for your help...sorry about the repost.
    >
    >
    >
    >
    >
    >
    > CREATE PROCEDURE [dbo].[spPreTranInsert]
    > (@PreTransactionID [int]=000000 output,
    > @GivenName [varchar](50),
    > @LastName [varchar](50),
    > @Address [varchar](250),
    > @City [varchar](50),
    > @State [char](10),
    > @PostCode [varchar](20),
    > @Country [varchar](200),
    > @Email [varchar](250))
    >
    > AS
    >
    > INSERT INTO [dbo].[tbPreTransactions]
    > ([GivenName],
    > [LastName],
    > [Address],
    > [City],
    > [State],
    > [PostCode],
    > [Country],
    > [Email])
    >
    > VALUES
    > (@GivenName,
    > @LastName,
    > @Address,
    > @City,
    > @State,
    > @PostCode,
    > @Country,
    > @Email)
    > GO
    >
    >
    > Dim cmdInsert__GivenName
    > cmdInsert__GivenName = Session("MemFormGivenName")
    >
    > Dim cmdInsert__LastName
    > cmdInsert__LastName = Session("MemFormLastName")
    >
    > Dim cmdInsert__Address
    > cmdInsert__Address = Session("MemFormAddress")
    >
    > Dim cmdInsert__City
    > cmdInsert__City = Session("MemFormCity")
    >
    > Dim cmdInsert__State
    > cmdInsert__State = Session("MemFormState")
    >
    > Dim cmdInsert__PostCode
    > cmdInsert__PostCode = Session("MemFormPostcode")
    >
    > Dim cmdInsert__Country
    > cmdInsert__Country = Session("MemFormCountry")
    >
    > Dim cmdInsert__Email
    > cmdInsert__Email = Session("MemFormEmail")
    >
    > set cmdInsert = Server.CreateObject("ADODB.Command")
    > cmdInsert.ActiveConnection = MM_connDANSW_STRING
    > cmdInsert.CommandText = "dbo.spPreTranInsert"
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@RETURN_VALUE", 3,
    > 4)
    > cmdInsert.Parameters.Append
    > cmdInsert.CreateParameter("@PreTransactionID",
    > 3, 2)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@GivenName", 200,
    > 1,50,cmdInsert__GivenName)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@LastName", 200,
    > 1,50,cmdInsert__LastName)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Address", 200,
    > 1,250,cmdInsert__Address)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@City", 200,
    > 1,50,cmdInsert__City)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@State", 129,
    > 1,10,cmdInsert__State)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@PostCode", 200,
    > 1,50,cmdInsert__PostCode)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Country", 200,
    > 1,200,cmdInsert__Country)
    > cmdInsert.Parameters.Append cmdInsert.CreateParameter("@Email", 200,
    > 1,250,cmdInsert__Email)
    > cmdInsert.CommandType = 4
    > cmdInsert.CommandTimeout = 0
    > cmdInsert.Prepared = true
    > cmdInsert.Execute()
    >

    Lionstone 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