Supportforum

Help, Feedback, Feature-Requests, Tipps for OASIS-SVN

Dear users and customers in Russia and Belarus
Please understand that we will currently not accept any orders from the Russian Federation or Belarus during the current conflict and the illegal invasion of Ukraine.
Also we will not offer any support or technical assistance for the affected countries.
We feel obliged to support the wide network of sanctions and to take a clear stance.
#StandWithUkraine

GUID's

GillesB created the topic: GUID's

GUID's (GlobalUniqueIdentifier) bieten eine einfache Möglichkeit, auch in Mehrbenutzer- oder Mehrschichtumgebungen wirklich eindeutige Primärschlüssel zu garantieren.
Diese können zu jeder Zeit im Code generiert und dann in das ID-Feld einer Tabelle eingetragen werden, ohne dass es beim Update zu Problemen mit anderen Benutzern kommt.

Der Code dazu ist wenig spektakulär:
Private Type TGUID
  D1 As Long
  D2 As Integer
  D3 As Integer
  D4(7) As Byte
End Type

Private Declare Function StringFromGUID2 Lib "ole32" (ptrGUID As TGUID, _
  ByVal ptrString As Long, ByVal lngSize As Long) As Long
Private Declare Function CoCreateGuid Lib "ole32" (ptrGUID As TGUID) As Long

Public Function CreateClassID() As String
Dim GUID As TGUID
Dim lngResult As Long
Dim strGuid As String
  If CoCreateGuid(GUID) = 0 Then
    strGuid = String(40, vbNullChar)
    lngResult = StringFromGUID2(GUID, StrPtr(strGuid), Len(strGuid) - 1)
    CreateClassID = Left(strGuid, lngResult - 1)
  End If
End Function
Als Feldtyp für den PrimaryKey ist dann VARCHAR(40) die richtige Wahl.

Ab Access 2010 kann man dieses Wissen auch ideal für die neuen DataMacros einsetzen:
[img]images/content/createclassid.png
#68

Please Log in to join the conversation.

Warning: DOMDocument::loadHTML(): Unexpected end tag : li in Entity, line: 2 in /var/hosting/web/usr0000002/dev2dev.de/templates/yoo_finch/warp/src/Warp/Helper/DomHelper.php on line 47 Warning: DOMDocument::loadHTML(): Unexpected end tag : ul in Entity, line: 2 in /var/hosting/web/usr0000002/dev2dev.de/templates/yoo_finch/warp/src/Warp/Helper/DomHelper.php on line 47
We use cookies and embedded fonts on our website that are essential for the operation of the site. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.