Ask a Question related to Coldfusion Database Access, Design and Development.
-
Anj01 #1
insert statement runs twice in place of once
Hi
I am using a simple insert statement .The insert statement picks a variable
from the form and inserts it into the database.
I have no loops in the page
the code is :
<cfif isdefined("Form.Category")>
<cfquery name="InsertCat" datasource="ShoppingCart">
Insert Into ShoppingMstCategory(Category)
Values('#Form.Category#')
</cfquery>
</cfif>
The insert runs twice on its own.
Though if I use Query analyser to insert the statement only inserts once.
am I missing something
Thanks
Anj01 Guest
-
Help with INSERT INTO statement
I'm getting the following error on a query. I haven't seen this one before. Any ideas on what I'm doing wrong? Thanks. Error Executing Database... -
insert statement into a mySQL dB from PHP
I have an insert statement into a mySQL db from PHP 99% of the time the statement executes properly but occasionally no write to the db occurs,... -
INSERT statement contains fewer items than the insert list
The block of code below shows how I am inserting field values into my dbase table: strSQLStatement = "INSERT INTO tblArticles... -
Insert 100 rows in just one statement
Your auxiliary table is probably the best way. Populate it with as many rows as you like rather than doing multiple inserts when you need more than... -
Insert Statement help
Hello, I am having some difficulty keeping my data consistent throughout my tables. I have 3 tables that I need to be "synch'd up".... -
Kronin555 #2
Re: insert statement runs twice in place of once
Paste your whole page. This snippet is not enough to go on.
Kronin555 Guest
-
Anj01 #3
Re: insert statement runs twice in place of once
here is the whole page
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>cat update</title>
</head>
<body>
<cfif isdefined("Form.Category")>
<cfquery name="InsertCat" datasource="ShoppingCart">
Insert Into ShoppingMstCategory(Category)
Values('#Form.Category#')
</cfquery>
<cfelse>
<cfif isdefined("Form.CategoryEdit")>
<cfquery datasource="Shoppingcart">
UPDATE ShoppingMstCategory
SET
[Category] = '#Form.Category#'
WHERE CategoryID = #Form.EditId#
</cfquery>
</cfif>
</cfif>
</body>
</html>
Anj01 Guest
-
Kronin555 #4
Re: insert statement runs twice in place of once
So this page is the action on a form post? Are users double-clicking the submit
button on the form?
There's nothing on this page that would cause a double-insert. If this page is
being posted to twice, that would cause a double insert.
Kronin555 Guest
-
mxstu #5
Re: insert statement runs twice in place of once
It does sound like it might be a double post problem.
If the values in the table should be unique, you might consider making the
insert conditional so that the form value is only inserted if it does not
already exist in the table.
mxstu Guest



Reply With Quote

