472,960 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Getting Syntax error converting from a character string to uniqueidentifier

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 called fileIds that is oftype varchar.
I am putting in a comma separated string with ids (such as:'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22','9B176B0C-CA03-49C9-A2E7-063038E7CF23')

However, when I execute the sp via my dataadapter.fill I get thementioned "Syntax error converting from a character string touniqueidentifier" back.
To me it seems like the IN part doesn't like the comma separatedstring with unique ids :-(

select
*
FROM
Files
WHERE
Files.FileID IN(@FileIds);
The strange stuff is that the sp works correctly when I executeit from the query analyzer !

By the way - I am using a typed dataset in the fill command, butI have verified the results several of times and it seems to becorrect (for instance, I have let the dataadapter create a newdataset and compared it with my typed dataset - they areidentical) I have also tried to select everything without thewhere part and it works fine - so I guess the problem is in the"IN (@FileIds)" - part ?
Please, help me to shed a light on this problem.

/Roy.
--------------------------------
From: Roy Rodsson

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>bbiYAgQ3OU6ew03zELzN/A==</Id>
Nov 20 '05 #1
2 9242
* Roy Rodsson via .NET 247 <an*******@dotnet247.com> scripsit:
select
*
FROM
Files
WHERE
Files.FileID IN(@FileIds);


You will more likely get an answer here:

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<URL:http://msdn.microsoft.com/newsgroups/?dg=microsoft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
the problem is that when your sp gets the string is adds its own ' '
you would get
select
*
FROM
Files
WHERE
Files.FileID
IN(''9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7
CF22'');
1 whole string instaid of comma separated

I don't know a sollution to do this in an sp but i would execute it as
sqltext directly from vb. You don't put user input directly in the statement
and precompiled sp is useless since the condition always changes)
yust a thought

eric

"Roy Rodsson via .NET 247" <an*******@dotnet247.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
Hi all!

I am using a stored procedure in SQL2000 for retrieving file informations
from a db.
the table as an uniqueidentifier for the file information.

The stored procedure has a variable called fileIds that is of type varchar.
I am putting in a comma separated string with ids (such as:
'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22
','9B176B0C-CA03-49C9-A2E7-063038E7CF23')

However, when I execute the sp via my dataadapter.fill I get the mentioned
"Syntax error converting from a character string to uniqueidentifier" back.
To me it seems like the IN part doesn't like the comma separated string with
unique ids :-(

select
*
FROM
Files
WHERE
Files.FileID IN(@FileIds);
The strange stuff is that the sp works correctly when I execute it from the
query analyzer !

By the way - I am using a typed dataset in the fill command, but I have
verified the results several of times and it seems to be correct (for
instance, I have let the dataadapter create a new dataset and compared it
with my typed dataset - they are identical) I have also tried to select
everything without the where part and it works fine - so I guess the problem
is in the "IN (@FileIds)" - part ?
Please, help me to shed a light on this problem.

/Roy.
--------------------------------
From: Roy Rodsson

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>bbiYAgQ3OU6ew03zELzN/A==</Id>
Nov 20 '05 #3

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

Similar topics

3
by: Gizmo | last post by:
hello all have been trying to write a Mid() function a bit like the one in vb. i come to compile it and there are no errors however when i run it an error accours and it says the program has to...
1
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
1
by: amitbadgi | last post by:
I am gettign this error while converting an asp application to asp.net , its a query syntax error, Exception Details: System.Runtime.InteropServices.COMException: Syntax error in query expression...
2
by: brian_harris | last post by:
I am tring to use trimstart to remove leading zeros, but all things I try give a compiler error on converting data. I am programing in C++ .net vs2003. This is one of my earlier attempts to call...
2
by: Jukka Aho | last post by:
When converting Unicode strings to legacy character encodings, it is possible to register a custom error handler that will catch and process all code points that do not have a direct equivalent in...
1
by: SealedClassSingleton | last post by:
Hi, When calling a stored procedure on a SQL 2005 DB with the managed SQL ADOprovider I got the following exception: Syntax error converting character string to uniqueidentifier when I use...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
6
by: ewpatton | last post by:
Good day, I've been trying to work with SQL and an Access database in order to handle custom user profiles. I haven't had any trouble reading from my database, but inserting new entries into...
1
by: SnehaAgrawal | last post by:
Hi I get the error "Syntax error converting datetime from character string "for the following sql statement in Stored proc. SET @dynamicSQL =N'SELECT CUSTID,SHCodeLink FROM AccountMaster where...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.