to generate uniquekey please try this, u can modify my code.want any
description reply me
private string getPrefix(int count)
{
string PrefixString = "A";
Char[] PrefixArray =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
if (count > 0)
{
int maxcount = count / 1000;
if ((maxcount >= 0) && (maxcount <= 25))
{
PrefixString = Convert.ToString(PrefixArray
[maxcount]);
}
else if ((maxcount >= 26) && (maxcount <= 676))
{
int preCount = maxcount / 26;
PrefixString = Convert.ToString(PrefixArray
[preCount - 1]) + Convert.ToString(PrefixArray[preCount - 1]);
}
else if ((maxcount >= 677) && (maxcount <= 458329))
{
int preCount = maxcount / 677;
PrefixString = Convert.ToString(PrefixArray
[preCount - 1]) + Convert.ToString(PrefixArray[preCount - 1]) +
Convert.ToString(PrefixArray[preCount - 1]);
}
PrefixString = PrefixString + (Convert.ToString(1000 +
count));
}
return PrefixString;
}
On Nov 19, 1:40 am, "Stephen Russell" <[EMAIL PROTECTED]> wrote:
> >--ok...so you're saying it would be better just to use the unique timestamp
>
> as my unique identifier?
>
> No not at all! That is a sort component.
>
> .........................
>
> Stephen Russell -
>
> Senior Visual Studio Developer, DBA
>
> Memphis, TN
>
> 901.246-0159
>
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Jon Liu
> Sent: Tuesday, November 18, 2008 10:03 AM
> To: [email protected]
> Subject: [DotNetDevelopment] Re: Auto-generating a primary key
>
> ok...so you're saying it would be better just to use the unique timestamp as
> my unique identifier?
>
> On Tue, Nov 18, 2008 at 8:00 AM, Joe Enos <[EMAIL PROTECTED]> wrote:
>
> If after all of this you still want to proceed, I'd suggest a two-
> column primary key, with the userid being the first part, and a new
> regular integer being the second part. You can store "lastentryid" or
> "nextentryid" in an int column on the user table, then reference it
> whenever you need to insert a record.
>
> I don't think you can both access and increment this column from
> inside a function, so I think you'd either need to have your entire
> statement inside of a stored proc, or use two separate commands.
>
> On Nov 17, 9:50 pm, BigJ <[EMAIL PROTECTED]> wrote:
>
> > I see a formula section, but not sure how to go about it. I basically
> > have an primary key called "EntryId" and I want to consist of UserId
> > +unique counter, so if UserId="BigJ", and it's my first entry, then
> > EntryId="BigJ1" and the next entry would be BigJ2 etc....any insight
> > as to how to accomplish this? I know there is a formula field and I am
> > looking into it, but any insight or simple examples are apreciated, as
> > I left my SQL book at home lol...Thanks...
>
> No virus found in this incoming message.
> Checked by AVG -http://www.avg.com
> Version: 8.0.175 / Virus Database: 270.9.6/1797 - Release Date: 11/18/2008
> 11:23 AM