theoryofben
IS-IT--Management
I wasn't sure exactly how to phrase this but here goes. I have an asp.net page with vb.net for the code behind which does inserts on multiple tables. So I needed to generate a GUID that would act as a primary key on one table and foreign key on the others. I declared this as a Public Shared variable.
My understanding is that each time this page is loaded fresh a new id will be generated and available to all methods being used during that instance. This works fine on my development machine and two others that I test on. But on another machine, it doesn't.
I do an insert and then go do a second insert (after leaving the page) and the same GUID value is assigned which causes a primary key constraint error.
I realize I'm probably doing something royally stupid...but I need to know the answer. I just can't figure out why it works on some machines but not on others.
________________________________________________
[sub]"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison[/sub]
My understanding is that each time this page is loaded fresh a new id will be generated and available to all methods being used during that instance. This works fine on my development machine and two others that I test on. But on another machine, it doesn't.
I do an insert and then go do a second insert (after leaving the page) and the same GUID value is assigned which causes a primary key constraint error.
I realize I'm probably doing something royally stupid...but I need to know the answer. I just can't figure out why it works on some machines but not on others.
Code:
Public Class newentry
Inherits System.Web.UI.Page
Public leadid As Guid = System.Guid.NewGuid
Dim currentuser As Guid = CType(Membership.GetUser(User.Identity.Name).ProviderUserKey, Guid)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
bindDropdowns()
End If
________________________________________________
[sub]"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison[/sub]