Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Shmooter #1
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
-
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... -
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... -
Stored procedure?
Stored procedure ?? -- Message posted via http://www.dotnetmonster.com -
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... -
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... -
Lionstone #2
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



Reply With Quote

