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

Monday, March 19, 2012

Group Filter Not Working

I'm developing a simple client application, using local reports populated from a local dataset, which is in turn saved and read from xml.
I am trying to set up a VERY simple group filter expression and I'm running into problems. What I want to do is display all rows where a date column matches a parameter passed to the report. I'm setting the filter up using something like this:
Expression Operator Value
=Fields!SampleDate = =Parameters!DateParam
I keep getting the following error:

Processing Errors
Value cannot be null.
Parameter name: value
OK

I know I'm probably doing something wrong. The only filter that I could get to not give the error is 1=1. LOL. Please help!You may want to try this approach:

Filter expression:
=(Fields!SampleDate.Value = Parameters!DateParam.Value)

Operator:
=

Filter Value:
=True
-- Robert

Wednesday, March 7, 2012

Group By in Xml

Hi everybody!
First of all, execute me for my english, because I'm not English ...
I've got this kind Xml stored in a column (tmx) of my db (the name of
the table is TA_TMX) :
<tmx>
<header>
...
</header>
<body>
<tu>
<tuv lang=3D"EN">
<seg> Hello </seg>
</tuv>
<tuv lang=3D"Es">
<seg> Hola </seg>
</tuv>
</tu>
<tu>
<tuv lang=3D"EN">
<seg> Bye </seg>
</tuv>
<tuv lang=3D"Es">
<seg> Adios </seg>
</tuv>
</tu>
</body>
</tmx>
I want to do a query to obtain this:
IdTu Language Text
-- -- --
1 EN Hello
1 ES Hola
2 EN Bye
2 ES Adios
I mean, I want to get the language (lang attribute of tuv node) and the
text (text of seg node) of each tuv node. I've done this like this and
it works.
select ref.value('@.lang[1]','nvarchar(10)') as Language,
ref.value('seg[1]','nvarchar(max)') as Text
from ta_tmx cross apply tmx.nodes('/tmx/body/tu/tuv') as
R(ref)
where id_tmx=3D1
Besides I would like to know if it's possible to get the number of tu
node which belongs that tuv node to. So, =BFIs it possible to group by
tu node and get that column of numbers'
Thanks!Here's a solution, although I suspect there may
be a better way.
It requires a numbers table (created on the fly here).
with Digits(Num) as
(select 0 union all select 1 union all select 2 union all
select 3 union all select 4 union all select 5 union all
select 6 union all select 7 union all select 8 union all
select 9),
Numbers(Num) as
(select cast(a.Num + 10*b.Num as int)
from Digits a,Digits b)
select Numbers.Num,
ref.value('@.lang[1]','nvarchar(10)') as Language,
ref.value('seg[1]','nvarchar(max)') as Text
from ta_tmx
cross join Numbers
cross apply
tmx.nodes('/tmx/body/tu[position()=sql:column("Numbers.Num")]/tuv') as
R(ref)|||Slight improvement, change
cross join Numbers
to
inner join Numbers on Num between 1 and
tmx.value('count(/tmx/body/tu)','int')|||A simpler way
select ref.value('for $a in .. return count(../../*[. << $a]) + 1',
'int') as IdTu,
ref.value('@.lang[1]','nvarchar(10)') as Language,
ref.value('seg[1]','nvarchar(max)') as Text
from ta_tmx
cross apply tmx.nodes('/tmx/body/tu/tuv') as R(ref)
where id_tmx=1|||It works. Thank you very much.
Would you mind explaining me what you're doing here ?
" ref.value('for $a in .. return count(../../*[. << $a]) + 1', 'int')",
because I don't understand it.
Thanks in advance for your help.
Regards.|||for $a in .. return count(../../*[. << $a]) + 1
Here's a brief explanation of the above
The query uses nodes('/tmx/body/tu/tuv')
which generates subtrees from tuv downwards
such that . starts at the tuv level.
.. is the nodes parent.
"for a$ in .." assigns a$ to the current nodes parent (the tu node).
"count(../../*[. << $a])" returns the number of nodes
at the "tu" level that precedes the current node. The
../../* simply navigates back to the root from the "tu" node.
As this count won't include the current node we add one to give
the desired result.

Friday, February 24, 2012

GROUP BY and aggregate functions not supported with FOR XML AUTO

Hi All
I am trying to ouput the results from my query in the form of XML. The query
is like this:
SELECT a, b, COUNT(S.c ) AS x
FROM s
GROUP BY a,b
ORDER BY a,b
FOR XML AUTO, ELEMENTS
If run this, i get an error like this:
Server: Msg 6821, Level 16, State 1, Line 1
GROUP BY and aggregate functions are currently not supported with FOR XML
AUTO.
Is there any way i can do this? Thank you all in advance.MittyKom,
Try:
SELECT * FROM (SELECT TOP 100 PERCENT a, b, COUNT(c) AS x
FROM s
GROUP BY a,b
ORDER BY a,b ) AS Y
FOR XML AUTO, ELEMENTS
HTH
Jerry
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:2D6F411D-7CA3-4EEB-A05F-1FBF03FFE7E3@.microsoft.com...
> Hi All
> I am trying to ouput the results from my query in the form of XML. The
> query
> is like this:
> SELECT a, b, COUNT(S.c ) AS x
> FROM s
> GROUP BY a,b
> ORDER BY a,b
> FOR XML AUTO, ELEMENTS
>
> If run this, i get an error like this:
> Server: Msg 6821, Level 16, State 1, Line 1
> GROUP BY and aggregate functions are currently not supported with FOR XML
> AUTO.
> Is there any way i can do this? Thank you all in advance.|||SELECT a, b, x
FROM
(SELECT a, b, COUNT(S.c) AS x
FROM S
GROUP BY a, b) AS T
ORDER BY a, b
FOR XML AUTO, ELEMENTS ;
David Portas
SQL Server MVP
--

Sunday, February 19, 2012

Gripe: interoperability

Today I got the latest propaganda email from MSFT talking about XML and
interoperability. It's been bothering me all day and while the notion
of interoperability is good -- the ability to interact with disparate
heterogeneous platforms and protocols -- what really bugs me is the
choice of words.

Interoperability has 8 syllables, only 6 syllables shy of
"Supercalifragilisticexpialidocious". Plus Inter implies movement
between objects. When you fly between countries, it's going
international. When we're sending something within the company
firewall, we're working inside the intranet. However, we're not moving
between "operabilities".

What is operability? To operate; to use. The operator; the user.
Operable; usable or state of usefulness. Operability; WTF? If one
moment I was driving in my car and the next, I wreck my car -- then my
car has changed its state of usefulness. So my car experienced
interoperability?

Anyways...I found this old IEEE article about Interoperability. I still think
interoperability is a mouthful.

ftp://ftp.research.microsoft.com/pu...ll/98SEP-CD.pdf

GridView, XML, and .NET 2005 Application

Hello, I'm in the processing of learning .NET 2005 and an trying to rewrite
a simple command line application that I wrote a couple years ago. I have
the following requirements:
1) Read an XML file that I create with a list of .EXE and .DLL files.
2) Scan a directory based on the path stored within the XML file and extract
the production version information
3) Add the Path, Filename and version information to a GridView control.
Now I have item #3 working today which displays output to screen using
console.write.
Question 1:
How can I add headers to a datagrid and update with my own information based
on me scanning a directory?
Question 2:
My application today reads the file path information, etc., from SQL Server
and then scans the directory for the version information. I would like to
instead use an XML file to contain this information instead of SQL Server.
This way I can use ClickOnce easily deploy my application without having a
SQL Server requirement. Most of my updates will be done to the XML file
only, so I would simply like to republish my ClickOnce to have user
redownload new XML file.
What is the best way for me to create an XML file of my data that can be
maintained? I have columsn such as:
1) Filename
2) Path of file
3) Description
4) Shortname of file
Each row within the XML will be unique. I need a way that I can easily
update/create this file. I currently have about 200 rows in SQL that I need
to get into my XML file. I really do not want to retype all the
information, but I can if I have to.
Any help or direction with this would be appreciated.
You can save a DataSet as XML.
And something else you might want to think about. If the data displayed is
static, not requiring any user interaction, you might want to think about
optimizing your app by using an XSL transform to create the data in HTML in
the page, rather than a DataGrid. You can create an XSL style sheet, and use
an Xml WebControl to display it in any format you choose (as HTML).
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
"dm1608" <dm1608@.spam.net> wrote in message
news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
> Hello, I'm in the processing of learning .NET 2005 and an trying to
> rewrite a simple command line application that I wrote a couple years ago.
> I have the following requirements:
> 1) Read an XML file that I create with a list of .EXE and .DLL files.
> 2) Scan a directory based on the path stored within the XML file and
> extract the production version information
> 3) Add the Path, Filename and version information to a GridView control.
>
> Now I have item #3 working today which displays output to screen using
> console.write.
> Question 1:
> How can I add headers to a datagrid and update with my own information
> based on me scanning a directory?
> Question 2:
> My application today reads the file path information, etc., from SQL
> Server and then scans the directory for the version information. I would
> like to instead use an XML file to contain this information instead of SQL
> Server. This way I can use ClickOnce easily deploy my application without
> having a SQL Server requirement. Most of my updates will be done to the
> XML file only, so I would simply like to republish my ClickOnce to have
> user redownload new XML file.
> What is the best way for me to create an XML file of my data that can be
> maintained? I have columsn such as:
> 1) Filename
> 2) Path of file
> 3) Description
> 4) Shortname of file
> Each row within the XML will be unique. I need a way that I can easily
> update/create this file. I currently have about 200 rows in SQL that I
> need to get into my XML file. I really do not want to retype all the
> information, but I can if I have to.
> Any help or direction with this would be appreciated.
>
>
>
|||Thanks for the reply, Keven.
I'm trying to do away with using SQL Server. If I use the SaveToXML option
of ADO.NET, is the XML file the is created something that can easily be
maintained going forward? I guess I cannot control the output or format of
the XML file, so that is why I'm thinking it may not be what I want.
Opinions?
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
> You can save a DataSet as XML.
> And something else you might want to think about. If the data displayed is
> static, not requiring any user interaction, you might want to think about
> optimizing your app by using an XSL transform to create the data in HTML
> in the page, rather than a DataGrid. You can create an XSL style sheet,
> and use an Xml WebControl to display it in any format you choose (as
> HTML).
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> If you push something hard enough,
> it will fall over.
> - Fudd's First Law of Opposition
> "dm1608" <dm1608@.spam.net> wrote in message
> news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
>
|||I don't think it s a good idea to replace the database with an XML file. You
will loose all the benefits of concurrency control, backup/restore,
maintenance etc that the database provides you with.
You can store your XML in the database though either shredded (if it is
relational in nature) or natively...
Best regards
Michael
"dm1608" <dm1608@.spam.net> wrote in message
news:es1WSjb9FHA.2716@.TK2MSFTNGP11.phx.gbl...
> Thanks for the reply, Keven.
> I'm trying to do away with using SQL Server. If I use the SaveToXML
> option of ADO.NET, is the XML file the is created something that can
> easily be maintained going forward? I guess I cannot control the output
> or format of the XML file, so that is why I'm thinking it may not be what
> I want.
> Opinions?
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
>

GridView, XML, and .NET 2005 Application

Hello, I'm in the processing of learning .NET 2005 and an trying to rewrite
a simple command line application that I wrote a couple years ago. I have
the following requirements:
1) Read an XML file that I create with a list of .EXE and .DLL files.
2) Scan a directory based on the path stored within the XML file and extract
the production version information
3) Add the Path, Filename and version information to a GridView control.
Now I have item #3 working today which displays output to screen using
console.write.
Question 1:
How can I add headers to a datagrid and update with my own information based
on me scanning a directory?
Question 2:
My application today reads the file path information, etc., from SQL Server
and then scans the directory for the version information. I would like to
instead use an XML file to contain this information instead of SQL Server.
This way I can use ClickOnce easily deploy my application without having a
SQL Server requirement. Most of my updates will be done to the XML file
only, so I would simply like to republish my ClickOnce to have user
redownload new XML file.
What is the best way for me to create an XML file of my data that can be
maintained? I have columsn such as:
1) Filename
2) Path of file
3) Description
4) Shortname of file
Each row within the XML will be unique. I need a way that I can easily
update/create this file. I currently have about 200 rows in SQL that I need
to get into my XML file. I really do not want to retype all the
information, but I can if I have to.
Any help or direction with this would be appreciated.You can save a DataSet as XML.
And something else you might want to think about. If the data displayed is
static, not requiring any user interaction, you might want to think about
optimizing your app by using an XSL transform to create the data in HTML in
the page, rather than a DataGrid. You can create an XSL style sheet, and use
an Xml WebControl to display it in any format you choose (as HTML).
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
"dm1608" <dm1608@.spam.net> wrote in message
news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
> Hello, I'm in the processing of learning .NET 2005 and an trying to
> rewrite a simple command line application that I wrote a couple years ago.
> I have the following requirements:
> 1) Read an XML file that I create with a list of .EXE and .DLL files.
> 2) Scan a directory based on the path stored within the XML file and
> extract the production version information
> 3) Add the Path, Filename and version information to a GridView control.
>
> Now I have item #3 working today which displays output to screen using
> console.write.
> Question 1:
> How can I add headers to a datagrid and update with my own information
> based on me scanning a directory?
> Question 2:
> My application today reads the file path information, etc., from SQL
> Server and then scans the directory for the version information. I would
> like to instead use an XML file to contain this information instead of SQL
> Server. This way I can use ClickOnce easily deploy my application without
> having a SQL Server requirement. Most of my updates will be done to the
> XML file only, so I would simply like to republish my ClickOnce to have
> user redownload new XML file.
> What is the best way for me to create an XML file of my data that can be
> maintained? I have columsn such as:
> 1) Filename
> 2) Path of file
> 3) Description
> 4) Shortname of file
> Each row within the XML will be unique. I need a way that I can easily
> update/create this file. I currently have about 200 rows in SQL that I
> need to get into my XML file. I really do not want to retype all the
> information, but I can if I have to.
> Any help or direction with this would be appreciated.
>
>
>|||Thanks for the reply, Keven.
I'm trying to do away with using SQL Server. If I use the SaveToXML option
of ADO.NET, is the XML file the is created something that can easily be
maintained going forward? I guess I cannot control the output or format of
the XML file, so that is why I'm thinking it may not be what I want.
Opinions?
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
> You can save a DataSet as XML.
> And something else you might want to think about. If the data displayed is
> static, not requiring any user interaction, you might want to think about
> optimizing your app by using an XSL transform to create the data in HTML
> in the page, rather than a DataGrid. You can create an XSL style sheet,
> and use an Xml WebControl to display it in any format you choose (as
> HTML).
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> If you push something hard enough,
> it will fall over.
> - Fudd's First Law of Opposition
> "dm1608" <dm1608@.spam.net> wrote in message
> news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
>|||I don't think it s a good idea to replace the database with an XML file. You
will loose all the benefits of concurrency control, backup/restore,
maintenance etc that the database provides you with.
You can store your XML in the database though either shredded (if it is
relational in nature) or natively...
Best regards
Michael
"dm1608" <dm1608@.spam.net> wrote in message
news:es1WSjb9FHA.2716@.TK2MSFTNGP11.phx.gbl...
> Thanks for the reply, Keven.
> I'm trying to do away with using SQL Server. If I use the SaveToXML
> option of ADO.NET, is the XML file the is created something that can
> easily be maintained going forward? I guess I cannot control the output
> or format of the XML file, so that is why I'm thinking it may not be what
> I want.
> Opinions?
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
>