.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Browser refresh and duplicate insert,...again

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :ASP.Net
Hi Guys,

I have "duplicate ID insertion when user refreshes page" problem.

I looked and looked but can't find a quick fix (response.redirect to the page again is just
not an option,...want to keep the UI without flickering controls ..ajax used here) nor do I
want to add new columsn to the database.

page.IsPostback does not solve the issue either, since it is not a postback we are dealing with here.

I just wonder how the brwoser "refresh" triggers my button1.click sub in the first place - since
the button is not clicked. I guess the http header somehow has the click event in it.
Is there a, easy (vb.net) way to detect "refresh" and avoid the instertion.

i read the following "One way would be to use AJAX and call a web service / page method to handle the insert. "
Any suggestions how that would work?

View Complete Post

More Related Resource Links

WF restarting when Browser refresh?

HI, I made a WF to run in ASP.NEt button click event. If we click the button, WF is running fine. After WF started, if I click refresh option in browser, my WF is starting New instance again.Old instance is also running. I dont know why. I am using mozilla browser and WorkFlowApplication to run WF. ANy suggestions?

Formview check for duplicate value before insert

I've looked at some posts on here but I keep getting errors.  I am just trying to see if an email address exists already before the insert and if it does, have a label display that message to the user. From what I read so far, it looks like I could do a query in the ItemInserting event.  I just need help on the code.  Thanks in advance for any help.. Here is the Code Behind.....where I assume I can do the duplicate check in the ItemInserting event... Protected Sub duplicatecheck(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInsertingEnd   End Sub     Here is the formview page...   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="signup.aspx.vb" Inherits="signup" %> <! < <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">html xmlns="http://www.w3.org/1999/xhtml">head runat="server">   </ <<title></title>head>body>  <form id="form1" runat="server">  <div>      <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource2" Def

Violation of PRIMARY KEY constraint 'PK_User_Details'. Cannot insert duplicate key in object 'dbo

hi,i'm using sql server 2005 as backend for web development .In one of my database table User_Details, 'user_id' is the primary key ,and it is set to autoincrementing as follows.object count = objUser.countUid(); string count1 = Convert.ToString(count);            if (count1 == "0")            {                string uid5 = "U1";           objUser.addUser(string uid5);}else{               object uid = objUser.selectUid();                string usid = uid.ToString();                string uid2 = usid.Substring(1);                int uid3 = int.Parse(uid2);                uid3 += 1;                string uid4 = usid.Substring(0, 1);          

Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object


i am unable to insert values into my table when i am using primary key and foreign key in my tables i am sure that i have not voilated the constraints rules and its working well when i remove the constraints.....

Using browser / URL to load report, with rc:Toolbar=false, report does not refresh


I've got an app that hosts a browser control. In it, I loop through a set of reports (displaying a dashboard of them). The problem is, I don't want the toolbar to display, so I'm using rc:Toolbar=false. This gets the toolbar to not display, but the problem is, the reports don't refresh (I have timestamps in the reports, and they remain the same).

I'm not caching the reports- I have them set to the default setting of run the report each time.

So, how can I get both the toolbar hidden AND the report to be refreshed? I tried looking at the stylesheets, but can't figure out how to hide the entire report toolbar using those.



How to refresh page and dropdown after insert record from popup page


I have a page that is opened in a popup window from the main page. Once i click insert it pops up a message that says you have successfully added blah blah. Then once you click ok it closes the popup page and goes back to the main page. I want to be able to refresh the main page back to how it was when you first land on the page. Here is the code for my insert button:


 <asp:button id="insertButton" 
                    style="background-image:url('Images/Button.gif'); text-align:center;background-color:Transparent; cursor:hand; background-repeat:no-repeat; background-position:left; padding-left:15px; font-family: 'Arial Unicode MS'; font-size: small; font-weight: bold;" 
                    Runat="server" Height="25px" BorderStyle=None ForeColor=White    Text="Insert" 
                    Width="99px" CssClass="style13" CommandName="Insert" OnClientClick="javascript: alert('You have successfully added a New Donor!!');window.open('','_self','');window.close();" />


duplicate data on page refresh


I m working on ASP.Net database related project. I have one form including one Button, On ButtonClick I m inserting data into database.

It is working fine but when I m refreshing the page then again it is inserting same record into database.

I dont want this, so suggest me what  is the problem.

Thank's in advance.



list refresh after insert item

Hi, im having problems in a custom list, i develop a custom form with sl and configure a content type to use this form as a newform item, when i clic on new item all its fina my custom form is opened and i can insert the item the thing is when i close this form the custom list behind dont show the new item i mean this list don refresh by itself i have to press F5 to reload the page and see my new item in the list is there a way to make this automatically ? thanks in advance.

How refresh parent page from popup on Firefox & IE browser


I have used following codes and it will worked on IE but not in FireFox browser

1] <script langauge=""javascript"" type=""text/javascript"">window.opener.location=window.opener.location;</script>

2] window.opener.location.reload(true);

3] <script langauge=""javascript"" type=""text/javascript"">window.opener.location.href='../parentpage';</script>"

4] window.opener.location.reload(true);window.opener.location.href=window.opener.location;

Folder structure of pages are as like -

main folder (ABC) ---> sub folder 1(PQR) ---> parent page ( which needs to refresh )

                                 sub folder 1(PQR) ---> sub folder 2(XYZ) ----> popup page

From above structure, I need to refersh parent page which is in PQR folder from popup page which is in XYZ folder under PQR folder.

Please provide me javascript code which will work for both browser as IE and Firefox



Invisible parts by browser refresh


In my .aspx page, I use a div including some repeaters and datalists without update panel.

I bind all of them in page_load when Not IsPostBack condition is met.

by default page is ok but if I push refresh button on browser regardless which browser or simply push F5 it shows header but not that div.

I do not understand why.

Refresh Grid data - After Insert


I know there are many postings about this, but I've went through many and haven't figured how or when to rebind the grid to get the updated data. Can anyone give me some insight on how to do this. 


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserRoleAdmin.ascx.cs"
    Inherits="Admin_controls_UserRoleAdmin" %>
<%@ Register Assembly="obout_ListBox" Namespace="Obout.ListBox" TagPrefix="cc3" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc2" %>
<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="cc1" %>
<cc1:OboutDropDownList ID="OboutDropDownList1" runat="server" DataTextField="UserName"
    DataValueField="UserName" Width="300" DataSourceID="SqlDataSource1">
<cc1:OboutDropDownList ID="OboutDropDownList2" DataSourceID="SqlDataSource2" DataTextField="RoleName"
    DataValueField="RoleName" runat="server">
<br />
<cc1:OboutButton ID="OboutButton1" Text="Add To Role" runat="se

Cannot refresh OLAP-based data in Excel Services workbook in browser (SP 2010 / Project Server 2010)



In SharePoint 2010, Project Server 2010, Business Intelligence Center, upon attempting to refresh OLAP data in an Excel chart in the browser, the following error appears:

An error occurred during an attempt to establish a connection to the external data source.  The following connections failed to refresh:

My ODC Connection Name

We have loaded and configured Project Server 2010 according to spec (http://technet.microsoft.com/en-us/library/ee662109.aspx).  Excel Services is configured according to spec (global settings, trusted file locations, trusted data providers and trusted data connection libraries).  The Secure Store Service is configured with the ProjectServerApplication target application. 

Non-OLAP data refreshes of spreadsheet data work fine in the browser.  OLAP data refreshes in the Excel client itself work fine.  Only the OLAP refreshes in the browser fail.  The problem occurs whether using a Microsoft ODC or one that we created (saved in a trusted location).

The ULS log has only one error, which is:

06/21/2010 13:47:17.86  w3wp.exe (0x1238)               &

Cannot insert duplicate key row in object 'dbo.catalog'

Either I did a dumb thing, or SSRS 2005 is doing a dumb thing (or both?). Or maybe it's a SharePoint integration issue...

Here's what happened:

1. I published a report to the report library (we're in SharePoint integration mode)
2. In SharePoint, went to the new report and did "Edit Properties", and changed the report name in the Name field to a nicer, user-friendly name
3. Back to BIDS, I make a change to this same report and deploy again.
4. Now back in SharePoint, I see that there are two reports - the original one that I renamed in step 2, and this new one that I just deployed 
5. Now I delete the original one (with the nice new name), and rename this new one to that same exact name
6. When execute the report now, it won't run -- I get the following error:

Report Server has encountered a SharePoint error. (rsSharePointError)
Cannot insert duplicate key row in object 'dbo.catalog' with unique index 'IX_Catalog'. The statement has been terminated.
For more information about this error navigate to the report server on the local server machine, or enable remote errors 

The problem i

"Violation of PRIMARY KEY constraint . Cannot insert duplicate key in object ".

How this error could arise? I use data flow to insert rows from another server. I checked there is no duplicate key in primary key. thanks

How to avoid that BCP.exe insert stops when duplicate record exist?

I’m a migration consultant at Infor (Infor and Microsoft have a partnership) and we use in case the target database is SQL Server the bcp.exe to upload the data from old Baan-systems and legacy-systems into our core product “Infor ERP LN”.

The big, big problem with the bcp.exe is that loading stops as soon as a duplicate record exists. Is it possible to extend the bcp.exe to be able to load in append- and conventional mode like Oracle sql loader?
This is the big advantage of the Oracle High performance loader (sqlldr) where you can load the data in Conventional mode which creates the records per row!

I also heard that the bcp.exe will be replaced in future by another utility. We really hope this new utility don’t stop by each duplicate! Maybe you can provide me with more details about the new utility?

Many thanks in advance!

Cannot insert duplicate key. . Better message



When the user tries to save a record that includes a value that already exists it returns

"Cannot insert duplicate key row in object dbo.tblTableName with unique index IndexName"

I'd like to make this message read better for users - such as simply 'this record already exists'

Do I need to handle this in my application or can I configure something on the SQL database itself (e.g. table design or in the index) to return a more readable message.


Cannot insert duplicate key row in object 'Table' with unique index 'Column_Id' Problem


All, We have a User where there is an Access Application installed. Every Day he enters some Account Numbers in it. This Access application is hooked to SQL Server 2008 which updates a table in SQL Server. Now last 2 weeks user had some Connection Issues so he did not enter any Account Numbers in the Access application instead he just noted them on a Excel sheet.

Now I did not want him to insert manually, so I took that Excel sheet, loaded account numbers in a Temp table and tried to insert all the Missing Account Numbers in the Main table. But it failed with the following error: Note: Account_No has a Unique Non Clustered Index on it and it is not a Primary key also. How can I insert them? (There are no duplicate account numbers as well that I am trying to insert its all Unique Accout Numbers)

Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object 'dbo.Table_Name' with unique index 'Accoutn_No'.
The statement has been terminated.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend