i am creating a custom CustomerID by getting the first double characters of first name and last name taken from textboxes as following:
string CustomID = (FirstNameTxtbox.Value.Substring(0, 2) + LastNametxtbox.Value.Substring(0, 2));
string s = cmd.CommandText= " Select MAX(CustomerID) from Customers";
string CustomID = (FirstNameTxtbox.Value.Substring(0, 2) + LastNametxtbox.Value.Substring(0, 2) + (Convert.ToInt32(s)+1)) ;
Make the primary key an auto increment integer and the
CustomerID is a string that is computed based on the
ID, this way it will never duplicate.
You can set the
CustomerID can be something like
ex: First customer will have a primary key of 1, the
CustomerID will be
000001, next customer will be
000002 and so on.