There is a free component that will help you do this; it is called GUIDMaker and is available at
ServerObjects Inc.
If you have access to SQL Server from your ASP page, you can call the following script:
<% set conn = CreateObject("ADODB.Connection") conn.open "<connection string>" set rs = conn.execute("SELECT newid()") Response.Write rs(0) ' ... %> |
Or from ASP, you can use this:
<% Function GetGuid() Set TypeLib = CreateObject("Scriptlet.TypeLib") GetGuid = Left(CStr(TypeLib.Guid), 38) Set TypeLib = Nothing End Function Response.Write GetGuid() %> |
If you're wondering why we only take the left 38 characters out of the GUID, see
Article #2358.