Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Friday, March 30, 2012

Problem with CDATA section in XQuery

Hi,
i am trying to insert a CDATA section using XQuery in T-SQL. I am following
the example from books online
http://msdn2.microsoft.com/en-us/library/ms175466.aspx and i keep getting th
e
error 'XQuery [modify()]: Syntax error near '<!''
The code is:
DECLARE @.myDoc xml
SET @.myDoc =
'<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features> </Features>
</ProductDescription>
</Root>'
SELECT @.myDoc
SET @.myDoc.modify('
insert <![CDATA[ <notxml> as text </notxml> or cdata ]]>
into (/Root/ProductDescription/Features)[1] ')
SELECT @.myDoc ;
Does anyone have a solution for this?
Thanks,
Stefan
I think you can achieve the same effect by doing this
SET @.myDoc.modify('
insert text {"<notxml> as text </notxml> or cdata"}
into (/Root/ProductDescription/Features)[1]')|||Hello markc600@.hotmail.com,
Not really. If he really does want to use the CDATA tag here, he can't --
the content doesn't mater. I suspect, but XMLRW isn't parsing it correctly.
This smells like a bug to me.
Thanks,
Kent Tegels
http://staff.develop.com/ktegels/|||In this case I believe you should be able to use the text node constructor,
like
this
SET @.myDoc.modify('insert text{"<notxml> as text </notxml> or cdata"} into
(/Root/ProductDescription/Features)[1] ')
Denis Ruckebusch
SQL Server XML datatype test team
http://blogs.msdn.com/denisruc
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"mindflower" <mindflower@.discussions.microsoft.com> wrote in message
news:9DBECB6E-006B-4537-A039-CEEA784B9FD8@.microsoft.com...
> Hi,
> i am trying to insert a CDATA section using XQuery in T-SQL. I am followin
g
> the example from books online
> http://msdn2.microsoft.com/en-us/library/ms175466.aspx and i keep getting
the
> error 'XQuery [modify()]: Syntax error near '<!''
> The code is:
> DECLARE @.myDoc xml
> SET @.myDoc =
> '<Root>
> <ProductDescription ProductID="1" ProductName="Road Bike">
> <Features> </Features>
> </ProductDescription>
> </Root>'
> SELECT @.myDoc
> SET @.myDoc.modify('
> insert <![CDATA[ <notxml> as text </notxml> or cdata ]]>
> into (/Root/ProductDescription/Features)[1] ')
> SELECT @.myDoc ;
> Does anyone have a solution for this?
> Thanks,
> Stefan

Wednesday, March 7, 2012

Problem w/ Script Task accessing Directory Services

Using the example from SS online books:

The code is this:

Public Sub Main()

Dim directory As DirectoryServices.DirectorySearcher

Dim result As DirectoryServices.SearchResult

Dim email As String

email = Dts.Variables("email").Value.ToString

Try

directory = New _

DirectoryServices.DirectorySearcher("(mail=" & email & ")")

result = directory.FindOne

Dts.Variables("name").Value = _

result.Properties("name").ToString()

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

Dts.Events.FireError(0, _

"Script Task Example", _

ex.Message & ControlChars.CrLf & ex.StackTrace, _

String.Empty, 0)

Dts.TaskResult = Dts.Results.Failure

End Try

Dts.TaskResult = Dts.Results.Success

End Sub

End Class

My problem is I'm not getting a value for 'Name' instead when I display in a dataflow task (using dataviewer)following the script task the value of Name = 'System.DirectoryServices.ResultPropertyValueCollection'

It's seems like it is telling me its property not the value. I'm not a VB/.Net developer so I'm just guessing as to what the value means.

Any help would be appreciated.

thanks

I'm nod directory services expert, but from MSDN, the indexer of ResultPropertyCollection is declared as

Public ReadOnly Default Property Item ( _ name As String _ ) As ResultPropertyValueCollection

I.e. result.Properties("name") returns a collecions of properties, not the value.

|||

Found additional examples of how to do this and got it working

thanks

Saturday, February 25, 2012

Problem using Reporting Services forms authentication with SSL

I am using Reporting services 2005 and have enabled forms authentication using the example found in:
'C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Extension Samples\FormsAuthentication Sample'
This works correctly without SSL, but when I enable SSL I get an error when logging in. The symptoms are as follows. I can login to the reporting server (in my case <server>/ReportServer2) directory, but when I login to the report manager (in my case at <server>/Reports2) I get the following error:
'The underlying connection was closed: An unexpected error occurred on a send.'
Can anyone suggest why I might be getting this error?

Thank you,
Graham

Please check your RSWebApplication.config for the Entry ReportServerUrl. This should contain the correct reportserver url in this format

<UI>
<ReportServerUrl>https://<certificatename>/reportserver2</ReportServerUrl>
<ReportServerVirtualDirectory></ReportServerVirtualDirectory>

problem using ntext

Hi, I'm using a column(ntext) to store some long strings. An example of the string that I need to store is the following:

436;Implementing A Gang - Awareness Program/And A Middle SchoolGang Prevention Curriculum. Doctoral Th;Samuels;Donald J;MiamiIV;Administrators; At Risk; Child And Youth Studies; Community;Community Members; Drop Out Prevention; Educational Leadership;Law/Criminal Justice; Peer Counseling; Principals; Secondary Education

I wrote a store procedure that does it, but it seems that the columnspace is not enough for the above string. The string in fact, istruncated and only the following portion is stored in my table:

436;Implementing A Gang - Awareness Program/And A Middle School Gang Prevention Curriculum. Doctoral Th;Samuels;Donald J;MiamiIV;Administrators; At Risk; Child And Youth Studies; Community;Community Members; Drop Out Prevention; Educational Leadership

What can I do?

ChristianIf you are not storing more than 4000 characters you can use NVarChar 4000 is the limit. The reason there are issues with NText and limitations. Hope this helps.|||I have just changed the column type from text to varchar(4000).
But I still have the same problem.

Christian|||

Try the link below for working code sample. Hope this helps.

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.insertcommand.aspx

|||

christianmala:

I wrote a store procedure that does it, but it seems that the columnspace is not enough for the above string. The string in fact, istruncated and only the following portion is stored in my table:


How are you checking what is stsored in your table? I highly suspect you are using Query Analyzer, which by default will only display the first 256 characters in a column. To change this value in QA, Tools - Options - Results - Maximum characters per column. Change 256 to something larger.|||Oh God,
you are so right!!!!!

Thanks,

Christian