Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 April 6th, 2005, 01:27 PM
Authorized User
 
Join Date: Feb 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create Unique Id

Im manually creating a League id for new leagues in my site(Cant use autonumber). The problem is when i get to league 11, i get the following error:

Microsoft JET Database Engine error '80040e21'

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.

The League type is "Text" in access.

Here is my code:

dim strMemberId, dblMemberId
  if (rsUsers.BOF) AND (rsUsers.EOF) Then
    strMemberId = 1
  else
    rsUsers.MoveLast
    strMemberId = rsUsers("MemberId")

    If CDbl(Right(strMemberId, 2) >= 10) Then
      dblMemberId = CDbl(Right(strMemberId, 2))
    ElseIf cint(Right(strMemberId, 3)) >= 100 Then
      strMemberId = CDbl(Right(strMemberId, 3))
    ElseIf cint(Right(strMemberId, 4)) >= 1000 Then
      lngMemberId = CDbl(Right(strMemberId, 4))
    Else
      dblMemberId = CDbl(Right(strMemberId, 1))
    End If

  dblMemberId = dblMemberId + 1
  strMemberId = Cstr(dblMemberId)
  end if

  rsUsers.AddNew
  rsUsers("MemberId") = strMemberId

I think it has something to do with the cast operators but cant figure it out, Please Help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
generate unique id capri SQL Server 2000 1 April 6th, 2008 10:18 AM
SQL script to create a unique ID for records chubnut SQL Server 2000 1 October 16th, 2006 07:25 AM
create a unique id in asp code langer123 Classic ASP Basics 1 March 15th, 2005 03:55 AM
Creating a Unique ID for each row maxworlund SQL Server DTS 1 March 8th, 2005 09:33 PM
Getting Unique ID from Database Nicky_uk Classic ASP Databases 9 January 26th, 2005 04:45 PM





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