Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello, in my project(car rental system) ,in of the windows form application i want a unique receipt number generated when user completes the payment form.In cancellation form containing receipt no,emailand booked date when he fills receipt no ,his email_id and booked date should come automatically.i am having the user atble with all the fields like username,email...and booking table consists of booked date.plz help me...
Posted

In a database, set the id field to auto_increment for a unique, consecutive sequence. Generate GUIDs for random looking (i.e. unguessable) IDs – but GUIDs typically don't index as well as ints so I recommend having an auto_increment internal ID as the primary key even if you decide you want to be more opaque with what you display to the user.

A booking should be tied to a user and then the query you want is something like:
select booking.receiptno, booking.bookingdate, user.email from booking left join user on booking.user = user.username where booking.receiptno = @receiptno
 
Share this answer
 
Comments
Manfred Rudolf Bihy 3-Oct-11 10:55am    
Agreed! 5+

The internal (database) ID should never be made public and should at all times stay on the server side. :thumbsup:
satishmachineni 4-Oct-11 23:33pm    
thank u sir
Use Guid.NewGuid() it will give you a unique identifier.
 
Share this answer
 
create a GUID(). That is a unique key generate in .net.
 
Share this answer
 
public StudentDetails()
{
InitializeComponent();
BindEmpId();//caling the method here
}
private void BindEmpId()
{
con.Open();
cmd = new SqlCommand("select Roll_No from StudentDetails", con);
cmd.CommandType = CommandType.Text;
dr = cmd.ExecuteReader();
while (dr.Read())
{
temp = int.Parse(dr.GetValue(0).ToString());
}
txtRollNumber.Text = (temp + 1).ToString();
con.Close();
}
 
Share this answer
 
Comments
satishmachineni 4-Oct-11 23:33pm    
thank u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900