473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

convert string variable to uniqueidentifier

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

Nov 20 '05 #1
6 13458
"Sandy" <an*******@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
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

Nov 20 '05 #2
Another possiblity is that you need to setup your SqlParamater properly,
giving it a SqlType = UniqueIdentifier.

Nov 20 '05 #3
"Jeremy Cowles" <jeremy.cowles[nosp@m]asifl.com> wrote in message
news:sS*******************@twister.tampabay.rr.com ...
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.
Nov 20 '05 #4
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
Nov 20 '05 #5
"Sandra" <an*******@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
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.

Nov 20 '05 #6
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.
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
3
by: Wim | last post by:
I would like to store the ListView font in the XML config file. So I have a string variable listFont that stores the font (font.ToString()). It must be a string variable because a Font object...
2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
6
by: John Kotuby | last post by:
Hi all, I am using a 3rd party program in a VS2005 web project. The tool takes as input a string containing HTML and converts it to RTF. I have been creating a page by dynamically loading...
3
by: blazeboy | last post by:
Hello, I am using a SQL data source to insert records into a table. The table uses a GUID as the primary key (GoalEventID), and a GUID for a second field (GoalID) as a foreign key. When I call...
5
by: sagardeshmukh310 | last post by:
Sir, Following is my code Textbox tb = (TextBox)Convert.ToString(s) ; In above code i want to pass value present in the string variable 's' to the 'tb' variable but i am getting following...
2
by: bipinskulkarni | last post by:
Hi, i have a field createdby with datatype GUID. In following query ,i encountered with the error "Conversion failed when converting from a character string to uniqueidentifier" select...
3
by: kaushiknanda | last post by:
hey, I am pretty new to c++ programming and I am supposed to use system(const char*). But I have a string variable as the argument. Can any1 please help me how to use this string variable as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.