C# - Generate A Unique Number Without Database
Dec 10, 2010How do I generate a unique number in c# without the database? (max 17 digits). EDIT: digits only.
View 2 RepliesHow do I generate a unique number in c# without the database? (max 17 digits). EDIT: digits only.
View 2 RepliesI am generating a unique Ref number using this sql statement: SELECT REPLACE(STR(CAST(CAST(NEWID() AS binary(5)) AS bigint),12),0,0) as REF Subsequently, I need to insert this REF into sql database table in stored procedure. Here is what I did in my stored procedure:
USE [iBankRecords]
GO
/****** Object: StoredProcedure [dbo].[stp_addPayee] Script Date: 07/05/2010 21:57:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[stp_addPayee]
(
@CUSTID char(10),
@PAYEEACCNUM nvarchar(20),
@PAYEEACCTYPE char(10) ,
@PAYEENAME char(20),
@PAYERINITIAL char(20),
)
AS
DECLARE
@ReturnValue int
INSERT INTO PAYEE (CUSTID, PAYEEACCNUM,PAYEEACCTYPE,PAYEENAME,PAYERINITIAL, REF)
VALUES (@CUSTID,@PAYEEACCNUM,@PAYEEACCTYPE,@PAYEENAME,@PAYERINITIAL, REF)
IF @@ERROR<>0
BEGIN
PRINT 'ERROR'
SET @ReturnValue=1
RETURN @RETURNVALUE
END
ELSE
BEGIN
SET @ReturnValue=0
RETURN @RETURNVALUE
END
May I know how do I have generating a unique ref num and inserting the REF into the above statement?
How can I generate unique numbers in JQuery? I use the unique numbers for the Shopping Cart ID.
View 6 RepliesI want to generate a unique random number everytime a user submits a form. As the form is submited the data of the form should be placed in a database and a unique random number should be generated so that the user can later use this unique random number to reterieve his details from the database that refer to his unique random id. The unique random number should be atleast 9 digits long.
View 3 RepliesI need to generate a Unique Reference number that has 7 digits.
It should be formatted in the following way:
1st: B (Ball), G (Gift), C (Cat)
2nd: represents year of booking A(2010), B(2011),C(2012), etc
3rd: represents the month of booking J(Jan),F(Feb),M(Mar),A(Apr),Y(May), U(Jun), L(Jul),G(Aug), S(Sep),O(Oct),N(Nov),D(Dec)
4th: days of booking A(1st) - Z(26th), 1(27th) - 5(31st)
5,6,7th: These are counters for the number issues each day. Each can be A-Z,0-9 giving a total of 46,656 combinations. So 0 is first, then 1, 2, 3, 4, 5, 6, 7, 8, 9, A-Z, then 00 to 0Z, then 10 to 1Z, then 20 to 2Z, etc
Now , the 1st Digit is a Character that I generate based on a condition and that shouldn't be a problem.
How generate the unique no. 1,2,3 and so on .... on button click of each new user ..
the code mentioned below is a readwrite coding in vb.net ...
but the problem is it generate the same id for different users on button click event... but i want the no. of times button clicked the new ids will be generated
[code]....
I am a beginner in ASP.NET using VB Code. I want to generate a Unique reference no by concortinating three column fields.Example:
Column unique reference no (System Generated) - 10
Column with Product Code (User Entry) - APPLE
Column with Product Title (User Entry) - FRUITS
Unique ref No = FRUITS/APPLE/10
I want to concatenate this three fields to the column Unique Ref No.
generating random numbers in texbox and then submit to database. code should check if the generated number already exist in database before submiting to database.
View 1 RepliesI have a webpage Default.aspx which generate the id for each new user after that the id will be subbmitted to database on button click on Default.aspx...
if onother user is also entering the same time the id will be the same ... till they press button on default.aspx
How to get rid of this issue...so that ... each user will be alloted the unique id ...
i m using the read write code to generate unique id ..
I need to generate 8 digit unique id in c#. On my site a user will register and I need to generate a unique id for him in c# code(I don't want this logic in DB), after inserting the id I need to save it in database.
Edit: I need that numbers to be generated in random manner everytime.
want to generate a url somthing like this
Ex: [URL]
now on the above url you can see after .aspx page they have added /1??Modal+Popup#
this subject line as a url
i know there is a tech of url rewriting , i also search more on net also but not getting any simple way to simple code
can any one asist me, i dnt want that ISAPI re-write and all that coz i need to install this with IIS
i want to automatically generate a unique string as orderID. I dont want to use Guid, it is not user frindly, and i dont want to use indexer either. any build-in datatype i can use?
View 11 RepliesI have to generate a unique customer code like this-
'cbd'+first letter of customer name+incrementer
here
cbd is hard coded means reamain fixed in each customer code first letter of cust_name is like
Bell Companies- B
and incrementer must be four digit number like 0001,0002,0888 etc.
Here incrementer
should start with 0001 for each customer means for EX-
BELL COMPANIES - CBDB0001
then it should increment for customers having name started with B
TEL POWERS- CBDT0001
then it should increment for customers having name started with T
I want to generate a unique random number everytime a user submits a form. As the form is submited the data of the form should be placed in a database and a unique random number should be generated so that the user can later use this unique random number to reterieve his details from the database that refer to his unique random id. The unique random number should be atleast 9 digits long.
View 5 RepliesI have an ID field where I need to insert unique ID's
the ID should be like -
S- (YY)(MM)9999. where, (YY) is year, (MM) is month and 9999(is a four digit random number)
for example - S-11030001
How does System.Guid.NewGuid() know that the values it generates are unique, for example when i use in a loop?Does it internally store data somewhere? .
View 1 RepliesI want to know which code or technique is used to write the code written below in url which is "3rhgf6v4zbos16x" what is this and how it can be generated in asp.net?
[URL]...
i have an application where users are allowed to fill in a form, once saved the form is given a unqiue # in this format: YYYY/MM/DD/### where ### is a 3 digit number, starts at 001, next one would be 002, etc.. the the YYYY/MM/DD is the date the form was saved, so if we had 2 saved today we would get these two:
2011/01/10/001
2011/01/10/002
I just wanted to know how to be sure that those numbers are always unqiue, if two people submit a form at the same time to make sure they are not given the same number? As we had that happen recently now that the application is being used a lot more, two people saved about the same time and once someone clicked save twice while the first save was happening and 2 of the same IDs were generated. Just want to make sure no matter what a unqiue one is always generated. I 'm able to calculate the ###, just wanted to know if there is a way to make sure it's not being used by a process saving right now.
I have to generate a unique token no which will have three fields an incrementer,comp_code anddate.I have problem in generating a unique incrementer. Incrementer should be incremented by 1 like 0001,0002 etc, should be unique and based on no of record inserted.
View 5 RepliesI need to made a table like that:
Table customers
Name :
Number of customer:
So i must have a unique of customer , for every customer. Then if i try to insert a repeat number i will have a label saying that customer numer already exist. So you must choose this one. And the numer will appear. How can i do the code for a unique customer number ?
I have an easy problem for the experts here...been a few years since my last development work. I have an appl that will track complaints. When an administrator logs in, they go to the main admin.page. From there, they can create a new complaint record-here is where i'm stuck and am looking for a better way. When the admin loads the create.aspx page. i need a way go generate a unique number that i can insert into the db. What is the best way to generate the number...i don't care whether it's numerical or combo, just unique and durning postback the number does not change...the number will be given out as a reference back to the complaint... This seems pretty standard but I can't think of a way that will not duplicate numbers and am looking for best practice with low
View 3 Repliesi am trying to create a Unique order number so i tried to use the code above but every time i enter the quite the page the number get rest.
If (ViewState("counter") Is Nothing) Then
ViewState("counter") = 1
Else
ViewState("counter") = ViewState("counter") + 1
End If
OrderNum.Text = ViewState("counter")
If (ViewState("counter") Is Nothing) Then
I have a form and I want each form to have a unique number when it is filled out so it will go into the database. How can I set this up so when the page loads in the label it will say 1 then the second time it loads it will say 2?
View 1 RepliesI have developed a Portal (Request submission) which sends an Email and also it updates all values to the Database. What ever values gets updated to the database, will be sent as an email message to an address. It works fine. I need a Unique number to be generated for a Request submission which has to be sent in the Email message and also it has to be updated in the database. I use SQL Server 2005 and Framework 2, C# laungauge.
View 10 RepliesI have a system that generates a invoice in the form of a pdf document. I just want to know, what is the correct way to generate a reference number for the invoice. Preferebly I want something in the line of D100001, D100002 etc. The "D" stand for the kids school grade "D", "E","F" etc.
View 4 Replies