[英]How can I save a GUID correctly as a string?
I have GUIDs saved in a SQL server table which is linked to a MS-Access database (Data Type in Access: "Replication ID"). 我将GUID保存在链接到MS-Access数据库(Access中的数据类型:“复制ID”)的SQL Server表中。
In the forms I see the GUID like this: {CFFACB63-5EB1-43B2-BCCB-ACF6B226B4F4} 在表单中,我看到这样的GUID:{CFFACB63-5EB1-43B2-BCCB-ACF6B226B4F4}
Now I want to use the GUID in code it only shows as "????????" 现在我想在代码中使用GUID,它仅显示为“ ????????”
Dim strGuid As String
strGuid = CStr(Me.TransGUID)
Debug.Print " strGuid: '" & strGuid & "'"
Debug.Print " Len(strGuid): " & Len(strGuid) & ""
shows: strGuid: '????????', Len(strGuid): 8 显示:strGuid:'????????',Len(strGuid):8
I used GUIDs in code before and never had any problems and I see this the first time. 我以前在代码中使用过GUID,从来没有任何问题,这是我第一次看到。 I am confused what is happening here.
我很困惑这里发生了什么。 How can I save the GUID the way it is and why does it not save it in the way it should?
我如何按原样保存GUID,为什么不按应有的方式保存GUID? Any ideas?
有任何想法吗?
The GUID shows as strange characters like Chinese if I show the saved string in a form field. 如果我在表单字段中显示保存的字符串,则GUID会显示为类似于中文的奇怪字符。
Access has a built-in function to convert GUIDs to strings. Access具有将GUID转换为字符串的内置功能。
Dim strGuid As String
strGuid = StringFromGUID(Me.TransGUID)
Debug.Print " strGuid: '" & strGuid & "'"
While you can use native WinAPI functions to convert it, there's no need for that. 尽管您可以使用本机WinAPI函数进行转换,但不需要这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.