Showing posts with label sqlclient. Show all posts
Showing posts with label sqlclient. Show all posts

Tuesday, March 20, 2012

An unexplained error message for an Xquery

Hello,
When I issue this query:

select doc.query ('
for $b in /a/b,
$c in /a/c
return $b,$c
')
from T1
where id=6

I recieve this error message:
.Net SqlClient Data Provider: Msg 2227, Level 16, State 1, Line 5
XQuery [T1.doc.query()]: The variable '$c' was not found in the scope in which it was referenced.


Interestingly, when I reverse the order of the variables in the return clause (i.e. make it c$,$b ), the unidentified variable in the error message becomes $b instead of $c. i.e. the system always does not identify the second variable. The query always works fine if the return clause has only one variable, be it $b or $c.

Am I missing something here, or is it a bug?

thanks
-Arsany

The behavior is correct in this case. The problem here is with the precedence of the ',' operator with respect to the FLWOR statement. Basically, the ',' operator in the return statement is not binding to the return clause of the FLWOR, but rather creating a new XQuery expression. If you put parenthesis around the return statement (as shown below) this will enforce the precedence that you want in your query:

select doc.query ('
for $b in /a/b,
$c in /a/c
return ($b,$c)
')
from T1
where id=6
|||Thank you Mike
-Arsany Sawiressql

Thursday, March 8, 2012

An error has occurred when connecting to SQL Server 2005? but i am running SQL Server 2000

Hi all,

just wondering if anyone knows what may be causing this error:

"System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005"

This happens when trying to connect to a SQL Server 2000 database after running windows update on Server 2003. we believe that this is being reported by an updated ODBC driver rather than SQL Server itself. Although we have no idea of why it is doing this.

Could anyone please offer advice in this matter?

Thanks in advance,

Chris.

Beside this there has to be another message stating the inner message of the error. But in common you are right, the updatet driver for SNAC will cause to bring this new message.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||The error comes from SqlClient (managed). Please provide more details. Such as connection string, enabled protocols, etc. Please follow to the guideline: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=362498&SiteID=1