Page 1 of 1

Parameters & UniqueIdentifiers

Posted: Wed Jun 18, 2008 9:24 am
by jellis
Hi,

I have created a Parameter in my report which is a GUID called @ProjId

if I try to pass a value into it, I get a variety of errors as follows

If I pass in the GUID in any of these formats

f2ae04b3-ef47-4030-b897-4b005a523e7f
'f2ae04b3-ef47-4030-b897-4b005a523e7f'
{f2ae04b3-ef47-4030-b897-4b005a523e7f}

I get 'Input string was not in the correct format' followed by 'Failed to convert a parameter value from string to a guid.'

However if I embed the value into the report query directly inside single quotes, i.e;

WHERE ProjectId = 'f2ae04b3-ef47-4030-b897-4b005a523e7f'

The report executes as expected. SO my question is, how do I pass a GUID into a parameter?

Thanks,

Jon.


Parameters & UniqueIdentifiers

Posted: Thu Jun 19, 2008 1:58 am
by Edward
Hello, Jellis.

Please try the following expression:

Code: Select all

new Guid("f2ae04b3-ef47-4030-b897-4b005a523e7f");
P.S. For declaring of the variable with this sort of initializing please use Guid(Nullable) datatype.

Thank you.

Parameters & UniqueIdentifiers

Posted: Thu Jun 19, 2008 3:14 am
by jellis
Thanks Edward.

I actually achieved what I wanted by using a variable in my SQL statement and passing a value into that. Is there any advantage in using variables or parameters? They both seem to achieve the same thing?

Jon.

Parameters & UniqueIdentifiers

Posted: Mon Jun 23, 2008 4:29 am
by Edward
Hello, Jon.

In that case can be used variables as well as parameters. Meaning is the same. But assigning of the variables is possible outside the report from the main application, when the DataSource object is not created, but you need to assign a value.

Thank you.