Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Tuesday, March 20, 2012

associated xsl file will not format working xml template

I am just trying to get (what I thought was) a simple xsl file to
format (--> HTML) a simple xml query specified in a template file.
I do not get any message in the browser (except: page not found) or in
the Windows event viewer.
I am able to execute a URL query with no problems.
I am able to execute the template query.
When I specifiy the xsl file, no information appears.
I would like to know where/how this type of problem can be debugged.
I would be happy to post the short xml and xsl file here if that could
illuminate this problem.
TIA.
Regards..
"Relishguy" <dbsearch04@.yahoo.com> wrote in message
news:84e6fe3d.0406140716.15af040a@.posting.google.c om...
[snip]
> I would like to know where/how this type of problem can be debugged.
The best way to debug this type of problem is to debug the xsl since that is
usually where the problem is. You can post it here if you want and I would
also suggest saving an XML file that has the results from your query and
then linking the stylesheet to it and opening it in IE.
Bryant
sql

Monday, March 19, 2012

assigning xml output

I have a small question.
I am recently started using 2005 and I want to assign results of following
query in to a variable of any type.
select top 1 * from dbo.authors for xml auto
Please let me know how do I achieve this.
Kishortry using for xml path()
--
"kishor" wrote:

> I have a small question.
> I am recently started using 2005 and I want to assign results of following
> query in to a variable of any type.
> select top 1 * from dbo.authors for xml auto
>
> Please let me know how do I achieve this.
> Kishor|||and use it this way. Hope this helps.
declare @.a varchar(8000)
set @.a= (select top 1 * from dbo.Authors for xml path('AUTHORS') )
select @.a|||Hi
I got error.
Line 2: Incorrect syntax near 'xml'.
Kishor
"Omnibuzz" wrote:

> and use it this way. Hope this helps.
> declare @.a varchar(8000)
> set @.a= (select top 1 * from dbo.Authors for xml path('AUTHORS') )
> select @.a
>|||This works only is SQL Server 2005. You are using SQL 2005 right?

Assigning XML data to variables

Hi Guys...

Need some assistance here again.
What data type should I use for the variable that I receive from a resultset?

I tried setting it to object, but I encountered some problem later in the stage during the data flow because the XML source adapter cannot get the variable.

I tried setting it to String but get some error during runtime because of invalid datatype.

The main purpose here is actually to get the data from an XML column in a table and populate it into the XML Source Adapter so that I can do some transformations.

Any ideas?

Thanks.Hi,
Yes, this is definitely an issue. In the next release (post- CTP15) you will be able to put the XML result set into a string variable that can then be consumed by the XML Source Adapter. For now, you might be able to work around it with a script component that creates a new string variable and populates it with the data from the object variable. I'm sorry I don't have a better answer for you.

Thanks,
Mark

assigning variables

Thanks for all the help, just one last question on xml, using the following
code
DECLARE @.hDoc int
Declare @.RptType varchar(10)
Declare @.RptNo varchar(6)
EXEC sp_xml_preparedocument @.hDoc OUTPUT, @.TESTXML
Select * from OpenXML(@.hDoc, '//Header') with
(reportType varchar(10), reportNumber VarChar(6), batchNumber varchar(6),
reportSequenceNumber varchar(6), userNumber varchar(6) )
EXEC sp_xml_removedocument @.hDoc
when running this query, how can i assign the reportType to @.rptType and
reportNumber to @.RptNo
Peter,
You can try:
DECLARE @.hDoc int
Declare @.RptType varchar(10)
Declare @.RptNo varchar(6)
EXEC sp_xml_preparedocument @.hDoc OUTPUT, @.TESTXML
Select @.RptType = reportType, @.RptNo = reportNumber
from OpenXML(@.hDoc, '//Header') with
(reportType varchar(10), reportNumber VarChar(6), batchNumber
varchar(6),
reportSequenceNumber varchar(6), userNumber varchar(6) )
EXEC sp_xml_removedocument @.hDoc
... Of course, you won't be able to select the rest of the values along with
these variable assignments, so if you want a result set back you'll have you
re-select from OpenXML without the variables.
"Peter Newman" <PeterNewman@.discussions.microsoft.com> wrote in message
news:7627529A-C675-4DF8-AA27-78F44C66F5EB@.microsoft.com...
> Thanks for all the help, just one last question on xml, using the
following
> code
> DECLARE @.hDoc int
> Declare @.RptType varchar(10)
> Declare @.RptNo varchar(6)
> EXEC sp_xml_preparedocument @.hDoc OUTPUT, @.TESTXML
> Select * from OpenXML(@.hDoc, '//Header') with
> (reportType varchar(10), reportNumber VarChar(6), batchNumber
varchar(6),
> reportSequenceNumber varchar(6), userNumber varchar(6) )
> EXEC sp_xml_removedocument @.hDoc
> when running this query, how can i assign the reportType to @.rptType and
> reportNumber to @.RptNo

Sunday, March 11, 2012

Assigning the for xml query output to a variable

Hi,
I would like to generate an XML query using the 'for xml' clause and assign
that to a text variable for further manipulation.
for e.g., I would like to do some thing like this.
declare @.test text
Set @.test = Select * from test_table for xml auto
But this gives my the syntax error. Can anyone help capturing the xml output
of a query into a variable?
Regards,
ArunHi
Have you looked at the text datatype limitations. You can not use a lot of
the T-SQL string manipulation functions against it, so you can't really do
much with it once you have it.
You can do a SELECT ... INTO ... to write it to a temporary table, then
select it into your @.test variable. I have not tried it, but is a
suggestion.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Arun" <kathir_arun@.hotmail.com> wrote in message
news:ePOh0u8QFHA.576@.TK2MSFTNGP15.phx.gbl...
> Hi,
> I would like to generate an XML query using the 'for xml' clause and
> assign
> that to a text variable for further manipulation.
> for e.g., I would like to do some thing like this.
> declare @.test text
> Set @.test = Select * from test_table for xml auto
> But this gives my the syntax error. Can anyone help capturing the xml
> output
> of a query into a variable?
> Regards,
> Arun
>

Thursday, March 8, 2012

Assign XML to variable

How do I assign XmlDocument results to a variable (so that I can pass it to a sp)?

I know that the following code works....

select * from tblUsers where userId = 1225 for XML raw

It returns "<row UserId="1225" LastName="Evans" FirstName="Stephanie" MiddleInitial=...."), which is what I want. But when I try to assign it, I get an error "Incorrect syntax near 'XML'."

declare @.strXml nvarchar(1000)

set @.strXml = (select * from tblUsers where userId = 1225 for XML raw)

Ideas?

It is not possible to do this in SQL Server 2000 using TSQL. You cannot consume the XML output on the server-side in any form. This is possible in SQL Server 2005 since there is a native XML data type and there are lot of improvements to FOR XML clause.

assign variable to an XML query's result

Can I set output of an XML query to a variable (SQL Server 2000)? The
following query does not parse:
DECLARE @.Xml NTEXT
SET @.Xml =
(SELECT D.*
FROM WSDMS..Documents D
WHERE D.ID = @.DocumentID
FOR XML AUTO)
It's not possible for sql2k.
-oj
<bbla32@.op.pl> wrote in message
news:1172081331.938350.4510@.l53g2000cwa.googlegrou ps.com...
> Can I set output of an XML query to a variable (SQL Server 2000)? The
> following query does not parse:
> DECLARE @.Xml NTEXT
> SET @.Xml =
> (SELECT D.*
> FROM WSDMS..Documents D
> WHERE D.ID = @.DocumentID
> FOR XML AUTO)
>

assign variable to an XML query's result

Can I set output of an XML query to a variable (SQL Server 2000)? The
following query does not parse:
DECLARE @.Xml NTEXT
SET @.Xml = (SELECT D.*
FROM WSDMS..Documents D
WHERE D.ID = @.DocumentID
FOR XML AUTO)It's not possible for sql2k.
--
-oj
<bbla32@.op.pl> wrote in message
news:1172081331.938350.4510@.l53g2000cwa.googlegroups.com...
> Can I set output of an XML query to a variable (SQL Server 2000)? The
> following query does not parse:
> DECLARE @.Xml NTEXT
> SET @.Xml => (SELECT D.*
> FROM WSDMS..Documents D
> WHERE D.ID = @.DocumentID
> FOR XML AUTO)
>

assign variable to an XML query's result

Can I set output of an XML query to a variable (SQL Server 2000)? The
following query does not parse:
DECLARE @.Xml NTEXT
SET @.Xml =
(SELECT D.*
FROM WSDMS..Documents D
WHERE D.ID = @.DocumentID
FOR XML AUTO)It's not possible for sql2k.
-oj
<bbla32@.op.pl> wrote in message
news:1172081331.938350.4510@.l53g2000cwa.googlegroups.com...
> Can I set output of an XML query to a variable (SQL Server 2000)? The
> following query does not parse:
> DECLARE @.Xml NTEXT
> SET @.Xml =
> (SELECT D.*
> FROM WSDMS..Documents D
> WHERE D.ID = @.DocumentID
> FOR XML AUTO)
>

Thursday, February 16, 2012

ASP.Net, Microsoft SQL Server 2005 and XML

Hi!
I work in a web site project which uses ASP.net and Microsoft SQL
Server 2005. I use XML and XSL for my pages. My problem is:
oAs the data in the database contain some characters that are not
allowed by XML structure, I used CDATA for all my fields in order to
store them in the XML file like that :
vignettes_xml = vignettes_xml + "<transcription_texte><![CDATA[" +
reader1.GetString(47) + "]]></transcription_texte>"
oBut After I realized that with CDATA I can't access to my XML
structures inside the field (knowing that some fields in the database
stored XML data). So I changed my field to normal writing like that:
vignettes_xml = vignettes_xml + "<transcription_texte>" +
reader1.GetString(47) + "]</transcription_texte>"
oThe problem is : with both the first and the second writing I have in
my XML variable transcription_texte an empty data. But in my database
every transcription_texte contains a long XML structure. I did not
understand what the source of the problem is.
Your answers can be very helpful.
Regards,
Djamila.
Hello djamilabouzid@.gmail.com,
Its not all that clear as what is cause a problem here because we don't know
what reade1.GetString(47) is actually returning.

> Hi!
> I work in a web site project which uses ASP.net and Microsoft SQL
> Server 2005. I use XML and XSL for my pages. My problem is:
> oAs the data in the database contain some characters that are not
> allowed by XML structure, I used CDATA for all my fields in order to
> store them in the XML file like that :
> vignettes_xml = vignettes_xml + "<transcription_texte><![CDATA[" +
> reader1.GetString(47) + "]]></transcription_texte>"
> oBut After I realized that with CDATA I can't access to my XML
> structures inside the field (knowing that some fields in the database
> stored XML data). So I changed my field to normal writing like that:
> vignettes_xml = vignettes_xml + "<transcription_texte>" +
> reader1.GetString(47) + "]</transcription_texte>"
> oThe problem is : with both the first and the second writing I have
> in my XML variable transcription_texte an empty data. But in my
> database every transcription_texte contains a long XML structure. I
> did not understand what the source of the problem is.
> Your answers can be very helpful.
> Regards,
> Djamila.
>
Thanks,
Kent Tegels
http://staff.develop.com/ktegels/
|||Also instead of trying to construct your XML using string concatenations,
why don't you use FOR XML?
Best regards
Michael
"Kent Tegels" <ktegels@.develop.com> wrote in message
news:b87ad747edd8c8b87741135600@.news.microsoft.com ...
> Hello djamilabouzid@.gmail.com,
> Its not all that clear as what is cause a problem here because we don't
> know what reade1.GetString(47) is actually returning.
>
> Thanks,
> Kent Tegels
> http://staff.develop.com/ktegels/
>

ASP.Net, Microsoft SQL Server 2005 and XML

Hi!
I work in a web site project which uses ASP.net and Microsoft SQL
Server 2005. I use XML and XSL for my pages. My problem is:
o As the data in the database contain some characters that are not
allowed by XML structure, I used CDATA for all my fields in order to
store them in the XML file like that :
vignettes_xml = vignettes_xml + "<transcription_texte><![CDATA[" +
reader1.GetString(47) + "]]></transcription_texte>"
o But After I realized that with CDATA I can't access to my XML
structures inside the field (knowing that some fields in the database
stored XML data). So I changed my field to normal writing like that:
vignettes_xml = vignettes_xml + "<transcription_texte>" +
reader1.GetString(47) + "]</transcription_texte>"
o The problem is : with both the first and the second writing I have in
my XML variable transcription_texte an empty data. But in my database
every transcription_texte contains a long XML structure. I did not
understand what the source of the problem is.
Your answers can be very helpful.
Regards,
Djamila.Hello djamilabouzid@.gmail.com,
Its not all that clear as what is cause a problem here because we don't know
what reade1.GetString(47) is actually returning.

> Hi!
> I work in a web site project which uses ASP.net and Microsoft SQL
> Server 2005. I use XML and XSL for my pages. My problem is:
> o As the data in the database contain some characters that are not
> allowed by XML structure, I used CDATA for all my fields in order to
> store them in the XML file like that :
> vignettes_xml = vignettes_xml + "<transcription_texte><![CDATA[" +
> reader1.GetString(47) + "]]></transcription_texte>"
> o But After I realized that with CDATA I can't access to my XML
> structures inside the field (knowing that some fields in the database
> stored XML data). So I changed my field to normal writing like that:
> vignettes_xml = vignettes_xml + "<transcription_texte>" +
> reader1.GetString(47) + "]</transcription_texte>"
> o The problem is : with both the first and the second writing I have
> in my XML variable transcription_texte an empty data. But in my
> database every transcription_texte contains a long XML structure. I
> did not understand what the source of the problem is.
> Your answers can be very helpful.
> Regards,
> Djamila.
>
Thanks,
Kent Tegels
http://staff.develop.com/ktegels/

Thursday, February 9, 2012

ASP.NET 2 Data Binding with SQL 2005 XML

I am starting a project where I will be using the XML data type in SQL Server 2005, and ASP.NET to display and update the content of the XML.
I've been digging around for a bit trying to find some sources that will explain the process of doing data binding in ASP.NET with the SQL XML, but haven't been able to locate anything too useful yet.
The XML will be charts, each holding 3 groups of 70 rows of data, each row having 5 fields (boolean, datetime, datetime, int, string).
I will need to pull 1 or more charts down to be rendered in a web page, modified, and then stored back to SQL.
I'm assuming from what I've read so far that this is possible, but I need more information and hopefully some examples.
I've worked somewhat with SQL 2000 and ASP.NET 2 (mostly hand-written pages), but want to get full bore into using VS2005 to do this. I am very familiar with XML, XSLT, HTML, C# and JavaScript, moderately familiar with SQL and VS.
Any leads to web sites and books that would help along these lines would also be appreciated.
Greg Collins [Microsoft MVP]
Visit Braintrove ( http://www.braintrove.com )
On Mar 21, 6:15 pm, "Greg Collins [Microsoft MVP]"
<gcollins_AT_msn_DOT_com> wrote:
> I am starting a project where I will be using the XML data type in SQL Server 2005, and ASP.NET to display and update the content of the XML.
> I've been digging around for a bit trying to find some sources that will explain the process of doing data binding in ASP.NET with the SQL XML, but haven't been able to locate anything too useful yet.
> The XML will be charts, each holding 3 groups of 70 rows of data, each row having 5 fields (boolean, datetime, datetime, int, string).
> I will need to pull 1 or more charts down to be rendered in a web page, modified, and then stored back to SQL.
> I'm assuming from what I've read so far that this is possible, but I need more information and hopefully some examples.
> I've worked somewhat with SQL 2000 and ASP.NET 2 (mostly hand-written pages), but want to get full bore into using VS2005 to do this. I am very familiar with XML, XSLT, HTML, C# and JavaScript, moderately familiar with SQL and VS.
> Any leads to web sites and books that would help along these lines would also be appreciated.
> --
> Greg Collins [Microsoft MVP]
> Visit Braintrove (http://www.braintrove.com)
Work with XML Data Type in SQL Server 2005 from ADO.NET 2.0
http://www.developer.com/net/net/article.php/3406251
XML data type tips in SQL Server 2005
http://www.codeproject.com/dotnet/XMLdDataType.asp
and...
http://www.google.com/search?hl=en&q=XML+data+type+SQL+2005+asp.net

ASP.NET +Inserting data from xml in SQL Server Database table from ASP.NET

hi

I want to read data from XML file and insert that data from XML file into the Database Table From ASP.NET page.

plz give me the code to do this using DataAdapter.Update(ds)

Hi There,

Below is a simple way to read xml data and update xml datatable to SQLserver database. ( Run a loop if you have multiple table to update )

DataSet dsXML =newDataSet();

dsXML.ReadXml(@."c:\XMLPath\file.xml");

if ( dsXML.Tables.Count > 0 )if ( dsXML.Tables[0].Rows.Count > 0 )

{

// Select table structure to dataadapter

OleDbDataAdapter dataAdapter =newOleDbDataAdapter("SELECT * FROM [" + dsXML.Tables[0].TableName +"] WHERE 1 = 2","YourConnectionString");

// Use dataadapter to update to readed xml data

dataAdapter.Update(dsXML.Tables[0]);

dataAdapter.Dispose();

}

}