DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 17 Jul 2007 07:58:12 -0700,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    David Whitchurch-Bennett am
          2    (WenYuan Wang [MSFT])
                 3    David Whitchurch-Bennett am
                 4    (WenYuan Wang [MSFT])


NULL GUID fields in a Nested Query   
Hi there,

Firstly, I hope this is in the right place!

I have a problem with a nested query I am generating at runtime.

My table (tblIndexValue) has values in every cell in all rows including the 
createdUserID column. The createdUserID's datatype is a GUID, and the table 
is in Access using Jet 4 to connect from .NET.

Here is the query, as captured in the immediate window: -

SELECT DocumentID, 
(SELECT value FROM tblIndexValue WHERE 
indexFieldID={7b47a555-9a8e-4336-acbf-12b170d46f71} AND 
departmentID={f7d75dd6-096c-43e1-9f25-285fbe74a547} AND 
DocumentID=Q.DocumentID) AS IV1, 
(SELECT createdUserID FROM tblIndexValue WHERE 
indexFieldID={7b47a555-9a8e-4336-acbf-12b170d46f71} AND 
departmentID={f7d75dd6-096c-43e1-9f25-285fbe74a547} AND 
DocumentID=Q.DocumentID) AS IVID1
FROM tblDocument AS Q 
GROUP BY Q.DocumentID;

IV1, i.e. the value field (a text value) displays fine. However, IVID1, the 
createdUserID file (a GUID) only shows NULLS. If I run the inner query on 
it's own (i.e. SELECT createdUserID FROM .... substituting the Q.DocumentID 
for any of my documentID GUIDs) it displays as expected.

Have I missed something here?

Many thanks,

David
Date:Tue, 17 Jul 2007 07:58:12 -0700   Author:  

RE: NULL GUID fields in a Nested Query   
Hello David,

It seems you meet an issue that Jet 4 provider could not get the GUID type 
filed in a Nested Query.

I have reproduced this issue on my side.

Under my investigation, I'm afraid this is an issue in Jet 4 rather than 
.net framework, because the same issue also occurs if I execute this sub 
query in Access 2003 directly. If I change the select sub query slight, the 
GUID really could be retrieved by Jet provider. But the type has been 
changed to String. Thus, I'm afraid this is an issue in the Jet 4 
implementation.
SELECT DocumentID, 
(SELECT ''+createdUserID 
FROM tblIndexValue WHERE DocumentID=Q.DocumentID) AS IVID1
FROM tblDocument AS Q 
GROUP BY Q.DocumentID;

Anyway, for you special issue, I don't think it is necessary to use Nested 
Query here. There is another approach, what about change it as below? In my 
opnion, the following code is clear and more effective. Hope this helps.

SELECT Q.DocumentID, T.tblIndexValue as IV1, T.createdUserID as TVID1
FROM tblDocument AS Q, tblIndexValue as T
where T.indexFieldID={7b47a555-9a8e-4336-acbf-12b170d46f71} AND 
T.departmentID={f7d75dd6-096c-43e1-9f25-285fbe74a547} AND 
T.DocumentID=Q.DocumentID

Please feel free to update here, If you have more concern. We are glad to 
assist you.
Have a great day, 
Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Wed, 18 Jul 2007 09:16:20 GMT   Author:  

RE: NULL GUID fields in a Nested Query   
Thank you Wen for an answer that works. The string conversion is great. 

The query I provided was seriosuly truncated for ease of reading here. 
Actually, it pulls back 'n' inner queries which require a table rotate. The 
number of inner queries vary depending on the number of fields the user has 
setup.

The ''+createUserID solves it for me, and I can convert the string to a GUID 
in code. Thanks again for such a quick response that works!

David

"WenYuan Wang [MSFT]" wrote:


> Hello David,
> 
> It seems you meet an issue that Jet 4 provider could not get the GUID type 
> filed in a Nested Query.
> 
> I have reproduced this issue on my side.
> 
> Under my investigation, I'm afraid this is an issue in Jet 4 rather than 
> .net framework, because the same issue also occurs if I execute this sub 
> query in Access 2003 directly. If I change the select sub query slight, the 
> GUID really could be retrieved by Jet provider. But the type has been 
> changed to String. Thus, I'm afraid this is an issue in the Jet 4 
> implementation.
> SELECT DocumentID, 
> (SELECT ''+createdUserID 
> FROM tblIndexValue WHERE DocumentID=Q.DocumentID) AS IVID1
> FROM tblDocument AS Q 
> GROUP BY Q.DocumentID;
> 
> Anyway, for you special issue, I don't think it is necessary to use Nested 
> Query here. There is another approach, what about change it as below? In my 
> opnion, the following code is clear and more effective. Hope this helps.
> 
> SELECT Q.DocumentID, T.tblIndexValue as IV1, T.createdUserID as TVID1
> FROM tblDocument AS Q, tblIndexValue as T
> where T.indexFieldID={7b47a555-9a8e-4336-acbf-12b170d46f71} AND 
> T.departmentID={f7d75dd6-096c-43e1-9f25-285fbe74a547} AND 
> T.DocumentID=Q.DocumentID
> 
> Please feel free to update here, If you have more concern. We are glad to 
> assist you.
> Have a great day, 
> Sincerely,
> Wen Yuan
> Microsoft Online Community Support 
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> 
> 
Date:Wed, 18 Jul 2007 05:24:03 -0700   Author:  

RE: NULL GUID fields in a Nested Query   
It's my pleasure. David.
You are welcome.

Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 19 Jul 2007 03:21:33 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us