i need a key for synchronisation and replication between the app & sqlight db and my server with a mssql db. On the server each entry gets a GUID ( newid() ). In the app i use this function:
GUID:
Sub generateGUID() As String
Dim r As ResultSet=sql1.ExecQuery("select lower(hex(randomblob(16))) as x")
r.Position=0
Dim guid As String=r.GetString("x").SubString2(0,8) & "-" & r.GetString("x").SubString2(8,12) & "-" & r.GetString("x").SubString2(12,16) & "-" & r.GetString("x").SubString2(16,20) & "-" & r.GetString("x").SubString2(20,32)
Return guid.ToUpperCase
End Sub
As far as i can test does the function what i want, but i´m not 100% sure if sqlight produces a true unique identifier with this way. Can anyone confirm it?
Ok, this looks like pretty much the same but without using the sql-component. The question is - is this truly unique?
In mssql (maybe it´s changed in newer versions) the guid is a combination of a random numbers (time based) and the primary nic´s mac-address. Microsoft guarantees that newid() is globally unique as long as no mac-address is spoofed, so in normal conditions it is unique. when i produce a guid only based on random values it can´t be guaranteed to be unique - or am i wrong?