Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server.createobject("scriptlet.typelib").guid

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi,

I am trying to use server.createobject("scriptlet.typelib").guid to generate a unique id that i can then insert in to my SQL table. Problem is it thinks there are quotation marks in the guid result and this breaks the insert statement.

I have searched google for an answer and can't seem to find one. Maybe someone here has tried the same thing and can help. Below is the code and results i have.

Thanks in advance.



Code:
	guid = server.createobject("scriptlet.typelib").guid
	
	guid = replace(guid,"{","")
	guid = replace(guid,"}","")
	guid = replace(guid,"-","")
	
	linktoLuniqueIDlink = guid
	
        contactUniqueid = rstemp2("uniqueid")

	mySQLupdatelinkto = "INSERT INTO wce_linkto (LuniqueID, LUTableName, LEntityID, LETableName) VALUES ('"&(linktoLuniqueIDlink)&"','"&("wce_history")&"','"&contactUniqueid&"','"&("wce_contact")&"')"
	call updateDatabase(mySQLupdatelinkto, rstempm1, "continueSendingcm1")

Error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark after the character string '44D9B51F56A74B229DFAC4B76EDAA9D3'.



If i response.write linktoLuniqueIDlink to the screen this is what i get the below result which looks clean..

1B421E59B8FE4836B6604E2F3AA36846
 
I'd suggest one of two options :

1. Print out the contents of mySQLupdatelinkto and see if you can spot the error in there, or try running it in Query Analyser etc

2. Use the Database to generate the GUID for you or just use an autocounter - gives several suggestions on how to do this and will not require the scriptlet.typelib component to be installed on the server, as well are removing any permissions / security issues etc.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Hi,

The SQL query result when printed is:

INSERT INTO wce_linkto (LuniqueID, LUTableName, LEntityID, LETableName) VALUES ('ED8D25D105C74460B58BD37893F6A7B4

It's the guid, it must be treat like it has hidden ' or something.
 
are you getting any errors from your ASP ? suggest you print out the value of the GUID prior to dropping it into the SQL statement.

You may also want to break the SQL Statement into smaller chunks to ensure that it is the GUID that is causing the issue or use the second option and get SQL Server to generate the GUID for you.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
The only error is this:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark after the character string 'ED8D25D105C74460B58BD37893F6A7B4'.


If i print the GUID it looks like ED8D25D105C74460B58BD37893F6A7B4 which looks fine. If i set the GUIC var to a static value of test it inserts fine so it is 100% the server.createobject("scriptlet.typelib").guid that is causing the issue.


With SQL creating the uniqueid, do you mean an auto number or is there another option in sql to generate say a 16 char unique id? I can't use a predifined sql auto incremtal number as other things are entered into the wce_hisstory table and they are alpha numeric.
 
This post has been solved, removing the last two characters from the string is the answer.

linktoLuniqueIDlink = left(linktoLuniqueIDlink , len(linktoLuniqueIDlink )-2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top