PC Review


Reply
Thread Tools Rate Thread

convert string variable to uniqueidentifier

 
 
=?Utf-8?B?U2FuZHk=?=
Guest
Posts: n/a
 
      23rd Feb 2004
I'm building a SQL String and I want to choose only the records that are part of the current contractID.

My Variable
Dim contrID = Request.Params("oId"

I put it into the SQL String
WHERE (JS_CRM.dbo.cntrct_cntct.ContractId = '" & contrID & "')

And I get the error message
Syntax error converting from a character string to uniqueidentifier

How do I convert my string to a uniqueidentifier???

Thanks

 
Reply With Quote
 
 
 
 
Jeremy Cowles
Guest
Posts: n/a
 
      23rd Feb 2004
"Sandy" <(E-Mail Removed)> wrote in message
news:8BE64355-B0AA-4FBA-B09A-(E-Mail Removed)...
> I'm building a SQL String and I want to choose only the records that are

part of the current contractID.
>
> My Variable:
> Dim contrID = Request.Params("oId")
>
> I put it into the SQL String:
> WHERE (JS_CRM.dbo.cntrct_cntct.ContractId = '" & contrID & "')
> And I get the error message:
> Syntax error converting from a character string to uniqueidentifier.


Is ContractId a GUID? If so, I don't think you need the single quotes around
your variable. If that's not the issue, then you need to check the value of
contrID to make sure it is in fact a valid GUID.

HTH
-
Jeremy

 
Reply With Quote
 
Jeremy Cowles
Guest
Posts: n/a
 
      23rd Feb 2004
Another possiblity is that you need to setup your SqlParamater properly,
giving it a SqlType = UniqueIdentifier.

 
Reply With Quote
 
Jeremy Cowles
Guest
Posts: n/a
 
      23rd Feb 2004
"Jeremy Cowles" <jeremy.cowles[nosp@m]asifl.com> wrote in message
news:sSt_b.99256$(E-Mail Removed)...
> Another possiblity is that you need to setup your SqlParamater properly,
> giving it a SqlType = UniqueIdentifier.


Looks like you're not using Parameters, so scratch that.


 
Reply With Quote
 
=?Utf-8?B?U2FuZHJh?=
Guest
Posts: n/a
 
      23rd Feb 2004
Hi Jeremy, thanks for responding. You are correct, contactId is a GUID. I removed the single quotes and the error message said Incorrect Syntax.

If you have any other ideas that would be great!

I tried using, but it said couldn't convert string to SqlGuid:

Public Function Parse(ByVal s As String) As SqlGuid

Return s
End Function
 
Reply With Quote
 
Jeremy Cowles
Guest
Posts: n/a
 
      24th Feb 2004
"Sandra" <(E-Mail Removed)> wrote in message
news:AA258C1D-BFC1-4072-AFE1-(E-Mail Removed)...
> Hi Jeremy, thanks for responding. You are correct, contactId is a GUID.

I removed the single quotes and the error message said Incorrect Syntax.

So if you step through the code, is the value of your string variable infact
a GUID? I am willing to bet that it is empty or missing part of the GUID.

 
Reply With Quote
 
=?Utf-8?B?U2FuZHJh?=
Guest
Posts: n/a
 
      25th Feb 2004
I actually did a Response.Write(myvariable) to output the variable at the top of the screen so I could see what it is putting in there. It displays exactly as it should be: {F4B7FBB9-29A3-4E22-B778-19CCDAAEBB4F

If I replace my variable with that exact output, it works.
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate without string or convert string to variable =?Utf-8?B?U1NCU3lzdGVtc0NsZXJr?= Microsoft Access Form Coding 5 6th Apr 2006 11:46 PM
Re: Convert String to variable contained in string Bruce Wood Microsoft C# .NET 0 14th Apr 2005 08:13 PM
Re: Convert String to variable contained in string Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 0 14th Apr 2005 07:31 PM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= Microsoft ASP .NET 2 26th Oct 2004 03:43 PM
How do I convert an integer variable to a string variable? =?Utf-8?B?ZHVtYmFzcw==?= Microsoft Excel Programming 2 21st May 2004 07:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.