Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting primary key after an insert
Message
From
21/06/2006 05:12:02
 
 
To
05/06/2006 17:27:42
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01127217
Message ID:
01130449
Views:
16
>I am using VB.NET to insert a record in a VFP table which contains a primary key field which is defined auto incremental. So, basically, I am doing something like this to insert the record:
>
>
>INSERT INTO School (Title) VALUES ("This is my school name")
>
>
>However, in that particular case, I need to insert child records right after. As oppose to SQL Server, I cannot rely on the identity field by adding it in my SQLInsert command. So, how would I proceed to get this key in order to insert the child records and have them linked to the proper parent?

Don't auto-generate the keys, I don't know if someone's already mentioned this but use Guids in .Net.

ie: (c#)
Guid id = Guid.NewGuid();
Auto-incrementing keys is a bad idea, your guids will be unique and you'll have the primary key to hand at all times.

Kev
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform