StormHosts Community  

Go Back   StormHosts Community > General > Programming Discussion
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Programming Discussion Need help with some code? Got any code samples you want to share with others? Post it here!

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
Old 03-01-2005, 12:11 PM   #1
Will
Registered User
 
Join Date: Nov 2003
Location: Bradford, UK
Posts: 284
Will is on a distinguished road
Create a GUID in ASP without a database! (VBScript)

This little snippet of code is brilliant! I can create a GUID without connecting to a database of any kind.

Function createGuid()
Set TypeLib = Server.CreateObject("Scriptlet.TypeLib")
tg = TypeLib.Guid
createGuid = left(tg, len(tg)-2)
Set TypeLib = Nothing
End Function

"Scriptlet.TypeLib" is apparently installed with Windows Scripting so it's on virtually every Windows 2000+ machine you'll ever use ASP on.
__________________
-----------------------------------------------------------
Docupro - Offering Custom Programming and Websites
Will is offline   Reply With Quote
Old 03-08-2005, 01:54 PM   #2
sijpie
Registered User
 
Join Date: Nov 2003
Location: Scotland
Posts: 21
sijpie
Will,

just to get my mind around this: you create a guid to attach to an item in your rss. Correct? Is this code dynamic, ie can I create RSS on the fly and it will assign the same guid to the same item each time?

perhaps you can clarify with an example of how you use it.
sijpie is offline   Reply With Quote
Old 03-09-2005, 08:07 AM   #3
Will
Registered User
 
Join Date: Nov 2003
Location: Bradford, UK
Posts: 284
Will is on a distinguished road
GUID's are useful for a few things non-database related. Maybe you wish to create a unique temporary folder or assign a session variable to a connected client? These would be where GUIDs would work great. They can also help create un-guessable URLs for software downloads. (A user logs in and you create a new folder with the file in it and create a hyperlink for them to download. Once the file is downloaded, the session expires or a time limit is reached - you can delete the folder and file.)

Without storing the GUID in a database, you can't generate RSS on the fly and assign a GUID using this function - as your GUID will be different each time.

Can I ask what you are planning? If you are using SQL Server, you can add a new column of UNIQUEIDENTIFIER and insert a NEWID() in each column to create a GUID for every record then include that on your RSS. If you are using Access or similar - then you could use this function to create a GUID and assign it to a text field in your table because as far as I know - Access does not support GUID fields.
__________________
-----------------------------------------------------------
Docupro - Offering Custom Programming and Websites
Will is offline   Reply With Quote
Old 03-09-2005, 04:13 PM   #4
sijpie
Registered User
 
Join Date: Nov 2003
Location: Scotland
Posts: 21
sijpie
Thanks Will, that has cleared things up.

I wasn't planning anything in particular, but just trying to understand the use.

cheers
sijpie is offline   Reply With Quote
Old 01-25-2006, 06:09 AM   #5
Will
Registered User
 
Join Date: Nov 2003
Location: Bradford, UK
Posts: 284
Will is on a distinguished road
ASP.Net version of the same code:

Dim myGuid as string
myGuid = System.Guid.NewGuid.ToString

(purely for my own future reference! )
__________________
-----------------------------------------------------------
Docupro - Offering Custom Programming and Websites
Will is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:26 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
Site and Content 2001 - 2007 StormHosts