Creating Custom Primary Key Help

Mar 4 2010 11:05 AM
Hi,

I was wondering if anyone could help me here, at the minute I'm not even sure if this is possible lol :(

I have a vb.net form connected to a database. The form itself is for adding a customer record to the database, what I want to do is...

the user enters the customer's first name, surname, phone number into textboxes.
when the user clicks "Save", I want to create the primary key then by taking the surname, then adding the last 4 digits of the phone number to the string
then finally save the record and update the dataset.

However, each primary key must be 14 characters long (10 for the surname, 4 for the phone number) so if the surname was say, only 6 characters long, then the remaining characters would be taken from the customer's first name until 10 characters are filled.

I have an idea how to do it, something like

count = 0
primarykey = ""

while count < 10
    primarykey =  surname.text
    if primarykey length < 10
      primarykey = primarykey & firstname.text
   
    primarykey = primarykey & last 4 digits of phonenumber.text

any help would be much appreciated and thanks in advance!!!!

Answers (1)