Group: Forum Members
Posts: 99,
Visits: 253
|
The vast majority of our table schemas use GUID's (uniqueidentifiers) as their primary keys. I am not able to save new entries back to the test table I am using and updates sometimes go through sometimes do not! I have a simple form based on the Maintenance Form. Attached is the debug log I captured. I did try to add code int he BO_BeforeAddNew proc that primes the GUID of the file: Private Sub IncdTypeBO_BeforeAddNew(ByVal e As MicroFour.StrataFrame.Business.BeforeAddNewEventArgs) Handles Me.BeforeAddNew Me.SQLGUID = New System.Guid() End SubWhich just brought up this most recent error as shown in the log. Also I never heard back on the Radio button issue I posted yesterday. The combo box appears to work now. But for the life of me I cannot make the RadioButtonGrp/Options work with the BO. Ben
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
There is a BeforeSave event on the business object... If you want to exclude fields from the concurrency checking, you'll need to implement row versioning. Add an extra column to the table that is an integer. You can call it Version, RowVersion, prefix_Version, whatever, it just has to be an integer. Then, change the UpdateConcurrencyType to OptimisticRowVersion and set the RowVersionOrTimestamp column to the name of that column. The business object will handle the rest. The trigger can then just ignore that column and the business object won't think there is a concurrency issue. You can also use a Timestamp column for concurrency, but in this case, the trigger would also modify that field since Timestamp columns are updated automatically by the system.
|
Group: Forum Members
Posts: 414,
Visits: 2.8K
|
Just wanted to share this function as I use guid's as well. Here is a good article on using guids as Primary Keys. These function's are somewhere in that article in C# but I just made a vb version of it. http://www.informit.com/articles/article.asp?p=25862&rl=1 Public Shared Function NewSeqGuid() As GuidDim laGuid() As Byte = System.Guid.NewGuid.ToByteArrayDim ldBaseDate As DateTime = New DateTime(1900, 1, 1)Dim ldNow As DateTime = DateTime.Now' Get the days and milliseconds which will be used to build the byte string Dim strucdays As TimeSpan = New TimeSpan((ldNow.Ticks - ldBaseDate.Ticks))Dim strucmsecs As TimeSpan = New TimeSpan((ldNow.Ticks _- ( New DateTime(ldNow.Year, ldNow.Month, ldNow.Day).Ticks)))' Convert to a byte array ' Note that SQL Server is accurate to 1/300th of a millisecond so we divide by 3.333333 Dim laDays() As Byte = BitConverter.GetBytes(strucdays.Days)Dim laSecs() As Byte = BitConverter.GetBytes(CType((strucmsecs.TotalMilliseconds / 3.333333), Long))' Reverse the bytes to match SQL Servers ordering Array.Reverse(laDays) Array.Reverse(laSecs) ' Copy the bytes into the guid Array.Copy(laDays, (laDays.Length - 2), laGuid, (laGuid.Length - 6), 2) Array.Copy(laSecs, (laSecs.Length - 4), laGuid, (laGuid.Length - 4), 4) Return New System.Guid(laGuid)End FunctionPublic Shared Function GetDateFromSeqGuid(ByVal guid As System.Guid) As DateTimeDim baseDate As DateTime = New DateTime(1900, 1, 1)Dim daysArray() As Byte = New Byte((4) - 1) {}Dim msecsArray() As Byte = New Byte((4) - 1) {}Dim guidArray() As Byte = guid.ToByteArray' Copy the date parts of the guid to the respective byte arrays. Array.Copy(guidArray, (guidArray.Length - 6), daysArray, 2, 2) Array.Copy(guidArray, (guidArray.Length - 4), msecsArray, 0, 4) ' Reverse the arrays to put them into the appropriate order Array.Reverse(daysArray) Array.Reverse(msecsArray) ' Convert the bytes to ints Dim days As Integer = BitConverter.ToInt32(daysArray, 0)Dim msecs As Integer = BitConverter.ToInt32(msecsArray, 0)Dim lddate As DateTime = baseDate.AddDays(days)lddate = lddate.AddMilliseconds((msecs * 3.333333)) Return lddateEnd Function
|