Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How to use this function
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to use this function

 Post Reply Post Reply Page  12>
Author
Crash1hd View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crash1hd Quote  Post ReplyReply Direct Link To This Post Topic: How to use this function
    Posted: 24 November 2003 at 8:47pm

I am having trouble with calling the following function?

'Generates a GUID
Function GenerateGUID()
 GenerateGUID = Mid(Server.CreateObject("Scriptlet.TypeLib").GUID, 1, 38)
End Function

'Generate a unique OIK
Function GenerateGUID(ByRef Connection, ByVal TableName, ByVal GUIDFieldName)
 Dim GUID, IsOk, SQL, RS
 IsOk = False
 
 Dim Counter
 Counter = 0
 
 'loop round generating new GUIDs until we've found one that hasn't been used yet!
 While Not IsOk
  Counter = Counter + 1
  
  GUID = GenerateGUID()
  
  SQL = "SELECT [" & GUIDFieldName & "] FROM [" & TableName & "] WHERE [" & GUIDFieldName & "]='" & GUID & "'"
  'Response.Write SQL & "<BR>"
  'Response.Flush
  
  Set RS = ExecuteQuery(Connection, SQL, False, True)
  
  If RS.EOF Then
   'No matching GUID found, so it really *is* unique
   IsOk = True
  End If

  Kill RS
 Wend
 
 'Response.Write "GenerateGUID took " & Counter & " attempts to generate a new GUID.<BR>"
 GenerateGUID = GUID
End Function

I thought you would call it like so

response.write GenerateGUID(Conn, CouponCode, CCode)

but it seems that I am incorrect!

Is there some code I am missing?

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 9:55pm
What's the error. You have two functions by the same name. Name one  makeGuid and one checkGuide and see what happens

Edited by Phat
Back to Top
Crash1hd View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crash1hd Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2003 at 11:35pm

Ok I changed it to this

<%

'Generates a GUID
Function MakeGUID()
 MakeGUID = Mid(Server.CreateObject("Scriptlet.TypeLib").GUID, 1, 38)
End Function

'Generate a unique OIK
Function GenerateGUID(ByRef Connection, ByVal TableName, ByVal GUIDFieldName)
 Dim GUID, IsOk, SQL, RS
 IsOk = False
 
 Dim Counter
 Counter = 0
 
 'loop round generating new GUIDs until we've found one that hasn't been used yet!
 While Not IsOk
  Counter = Counter + 1
  
  GUID = MakeGUID()
  
  SQL = "SELECT [" & GUIDFieldName & "] FROM [" & TableName & "] WHERE [" & GUIDFieldName & "]='" & GUID & "'"
  Response.Write SQL & "<BR>"
  'Response.Flush
  
  Set RS = ExecuteQuery(Connection, SQL, False, True)
  
  If RS.EOF Then
   'No matching GUID found, so it really *is* unique
   IsOk = True
  End If

  Kill RS
 Wend
 
 'Response.Write "GenerateGUID took " & Counter & " attempts to generate a new GUID.<BR>"
 GenerateGUID = GUID
End Function

Response.write GenerateGUID("Conn, CouponCode, CCode") '1

GenerateGUID("Conn, CouponCode, CCode") '2

%>

And now I get the following error useing number 1

SELECT [] FROM [] WHERE []='{8DA1D6A9-1C0F-4227-A211-550C4C747932}'

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'ExecuteQuery'

/test.asp, line 33

And Line 33 is   Set RS = ExecuteQuery(Connection, SQL, False, True)

so I know that there is a problem with

GenerateGUID("Conn, CouponCode, CCode")

when I use the above Number 2 I get this error

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment: 'GenerateGUID'

/test.asp, line 48



Edited by Crash1hd
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 12:49am
Its because your not providing all the arguments. Try

GenerateGUID(Conn, CouponCode, CCode)
Back to Top
Crash1hd View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crash1hd Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 1:03am

Originally posted by Mart Mart wrote:

Its because your not providing all the arguments. Try

GenerateGUID(Conn, CouponCode, CCode)

I tried that and forgot to add it :( lol it gives me

Microsoft VBScript compilation error '800a0414'

Cannot use parentheses when calling a Sub

/test.asp, line 49

GenerateGUID(Conn, CouponCode, CCode)
-------------------------------------^
thats replacing 
GenerateGUID("Conn, CouponCode, CCode")
for
GenerateGUID(Conn, CouponCode, CCode) right?
Then I try
Call GenerateGUID(Conn, CouponCode, CCode) and I get this error
SELECT [] FROM [] WHERE []='F2D4F72B-52B5-4CF9-B23B-E3ECB08F163B'

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'ExecuteQuery'

/test.asp, line 34



Edited by Crash1hd
Back to Top
Crash1hd View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crash1hd Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 3:54am

Ok I found the proper way to call it! see below

GenerateGUID Conn, "CouponCode", "CCode"

But I still get an error of

SELECT CCode FROM CouponCode WHERE CCode = 'B7D25AA2-0BA5-4A7A-AFDF-FDE0030831CC'

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'ExecuteQuery'

/test.asp, line 34

Line 34 is

Set RS = ExecuteQuery(Connection, SQL, False, True)

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 4:55am
Type mismatch has something to do with the data types. Make sure you're coparing the same thing to the same thing.

E.g. String to string
Back to Top
Crash1hd View Drop Down
Newbie
Newbie
Avatar

Joined: 24 November 2003
Location: Canada
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crash1hd Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 5:07am

Originally posted by Phat Phat wrote:

Type mismatch has something to do with the data types. Make sure you're coparing the same thing to the same thing.

E.g. String to string

Please explain when you say string to string do you mean the name of the field in the db to the one in the script? cause they match the one I still feel I am having trouble with is the one in red

GenerateGUID Conn, "CouponCode", "CCode"

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.