|
-
May 5th, 2003, 04:23 PM
#1
Thread Starter
Lively Member
STRING to GUID
Ok I've been trying and trying but can't figure it out.
I have a SQL 6.5 database that I need to run SQL statements searching a binary field which contains GUIDs. Now, before I run the query I have the string value of the GUID, for example "BC713507-8AB8-11D2-B4A9-0008C7FA5601".
Obviously I can't use that and get results so I need to convert it to the binary value first but I don't know how to in VB6.
If only this were SQL 7 then I could do it easily.
Please help!
-
May 5th, 2003, 08:12 PM
#2
Addicted Member
VB Code:
Private Type guid
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal pstCLS As Long, clsid As guid) As Long
Private Sub form_load()
Dim s As String
Dim x, i
Dim g As guid
s = "{BC713507-8AB8-11D2-B4A9-0008C7FA5601}"
CLSIDFromString StrPtr(s), g
For i = 0 To UBound(g.Data4)
x = x & Hex(g.Data4(i)) & " "
Next
Debug.Print Hex(g.Data1) & " " & Hex(g.Data2) & Hex(g.Data3) & x
if that isnt the right format for the fields you can
also get it as a byte array but looks byteswapped in kind
of weird way
VB Code:
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpszProgID As Long, pCLSID As Any) As Long
Dim guid(15) As Byte
' convert from string to a binary CLSID
CLSIDFromString StrPtr(s), guid(0)
For i = 0 To UBound(guid)
x = x & Hex(guid(i)) & " "
Next
Debug.Print x
when in doubt..news groups are your friend
http://groups.google.com/groups?as_q...&num=100&hl=en
Free Code, papers, tools, and more
http://sandsprite.com
-
May 6th, 2003, 08:26 AM
#3
Thread Starter
Lively Member
That is close, but the result I need is
73571BCB88AD211B4A90008C7FA5601
with using the byte array example I am getting
73571BCB88AD211B4A908C7FA561
It is missing 3 zeros...
-
May 6th, 2003, 08:31 AM
#4
Thread Starter
Lively Member
NM that, I figured it out.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|