Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 24th, 2006, 07:49 AM
Authorized User
 
Join Date: Sep 2006
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET ERROR

Hi,
Wondered if you can help resolve an error I'm having with my code written in asp.net1.1, vb2003 using an access database ? The error I receive is as follows :

Server Error in '/' Application.
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.


This error occurs intermittently within an e-commerce website when you click on the shop page to display a list of items for sale, which in turns create a cart. The pertinent code is shown below :

Code:
Function RandomNo()
        If Session("CartID") Is Nothing Then

            'Create random number
            Dim RandomNumber As Integer
            RandomNumber = int((1+99990 - 10001) * rnd) + 10001
            'Display random number - testing only
            lblRandom.Text += CStr("Value is:" & RandomNumber)
            lblRandom.visible=False

            'Create date parameter
            Dim dateNow as Date = Date.Now
            Dim dtcart = dateNow.ToString("dd/MM/yyyy")
            'Remove brackets from date
            Dim datenum = (Replace(dtcart,"/",""))
            'Response.Write("datenum")

            'Set session equal to random number and date
            Session("CartID") = RandomNumber & datenum
            'Response.Write(Session("CartID"))
            'Call Createcart Function
            createCart()
        End If
End Function

and....

 Function createCart()

        'Define cart

        objDT = New System.Data.DataTable("Cart")

        'Set date and time
        Dim dtNow as DateTime = DateTime.Now
        Dim ts as String
        ts = dtNow.ToString("dd/MM/yyyy"  & " " & "HH:mm:ss")

        'Updates Cart table in db
        UpdatetblCart(Session("CartID"),ts)

    End Function


Basically the first function creates a random number using 5 digits and then links this value with a date and time variable. I've tried increasing the random number from say 5 to 7 digits but no effect.

Also when this error appears in the browser window, if you click on refresh enough times, the error message disappears and the items are listed.
Any ideas - thanks ?








Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net hosting error compad ASP.NET 2.0 Professional 0 September 16th, 2008 03:25 AM
Error in Migrating Project from ASP to ASP.NET hbansal ASP.NET 1.0 and 1.1 Professional 0 September 12th, 2008 05:48 AM
Anyone HELP error ASP.NET in C# koco ASP.NET 1.0 and 1.1 Basics 4 June 5th, 2006 08:58 PM
ASP.NET Error vjain1 VS.NET 2002/2003 2 April 20th, 2005 12:52 PM
ASP.NET Using VB.NET Chapt 3 Code error? uh6uj All Other Wrox Books 1 February 26th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.