473,548 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to cast in an xml based dataset SELECT method?

Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".

Aug 4 '06 #1
11 3924
Hi Peter,

1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
reading the data.
2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name and
not a string literal: Select("myStrin gField 19.99")
3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off using
a DataView and setting the RowFilter property.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".

Aug 6 '06 #2
Thank you very much. I will attempt what you mention in #3. I think
that is a better method. Also, in #2, those are single left ticks, not
single quotes (the mark under the tilde on the keyboard as opposed to
the quote under the double quotes near ENTER) I use them as many of the
fields I use have whitespace in their column names. I just had not
removed them from this example using a name that does not have
whitespace in the column name.

Regards,

Peter

Dave Sexton wrote:
Hi Peter,

1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
reading the data.
2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name and
not a string literal: Select("myStrin gField 19.99")
3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off using
a DataView and setting the RowFilter property.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".
Aug 7 '06 #3
Hi Peter,

Ahh yes. #2 should be disregarded ;)

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you very much. I will attempt what you mention in #3. I think
that is a better method. Also, in #2, those are single left ticks, not
single quotes (the mark under the tilde on the keyboard as opposed to
the quote under the double quotes near ENTER) I use them as many of the
fields I use have whitespace in their column names. I just had not
removed them from this example using a name that does not have
whitespace in the column name.

Regards,

Peter

Dave Sexton wrote:
>Hi Peter,

1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
reading the data.
2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name
and
not a string literal: Select("myStrin gField 19.99")
3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off
using
a DataView and setting the RowFilter property.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".

Aug 7 '06 #4
Ok. I think I know the root of my problem.

How do I force the strong-typed dataset using an existing schema? For
example, here is the top portion of the XML file I am bringing into the
first dataset:

<?xml version="1.0" encoding="UTF-8" ?>
<IPDRDoc xmlns="http://www.ipdr.org/namespaces/ipdr"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" IPDRRecorderInf o
="qca.nortelnet works.com"
xsi:schemaLocat ion="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>19 70-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset >0</timeZoneOffset>
<callCompletion Code>CC</callCompletionC ode>
<originalDestin ationId></originalDestina tionId>
<hostName>GWC22 @WSCRCAAH00T</hostName>
<subscriberId>S TS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5 360b453206046f6 b626</uniqueCallId>
<ipAddress>199. 173.87.2</ipAddress>
<portNumber>294 4</portNumber>
<seqNum>4200064 </seqNum>
<averagePacketL atency>7</averagePacketLa tency>
<inboundByteCou nt>231040</inboundByteCoun t>
<outboundByteCo unt>230880</outboundByteCou nt>
<inboundPacketC ount>1444</inboundPacketCo unt>
<outboundPacket Count>1443</outboundPacketC ount>
<packetLossPerc entage>0.0</packetLossPerce ntage>
<packetDelayVar iation>0</packetDelayVari ation>
</IPDR>

This is a call record on a voip server. (in case you'd like to know). I
would have thought that by the very nature of XML formats, C# would
check the schema and appropriately set the datatypes in the first
dataset. Then I wouldn't have this casting issue. If you browse out the
IPDR format -

http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd

You'll see that strong typing should already occur. Is there something
I should be adding to my ReadXML method to enforce the schema into the
dataset?

Thanks ahead of time,

Peter

Dave Sexton wrote:
Hi Peter,

Ahh yes. #2 should be disregarded ;)

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you very much. I will attempt what you mention in #3. I think
that is a better method. Also, in #2, those are single left ticks, not
single quotes (the mark under the tilde on the keyboard as opposed to
the quote under the double quotes near ENTER) I use them as many of the
fields I use have whitespace in their column names. I just had not
removed them from this example using a name that does not have
whitespace in the column name.

Regards,

Peter

Dave Sexton wrote:
Hi Peter,

1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
reading the data.
2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name
and
not a string literal: Select("myStrin gField 19.99")
3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off
using
a DataView and setting the RowFilter property.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".
Aug 7 '06 #5
Odd thing, I try to force System.Data.Xml ReadMode.ReadSc hema in the
ReadXML, and the first dataset throws an error that ds.Tables[0] does
not exist. (.NET is making my grey early). urrgh.

Peter

MurdockSE wrote:
Ok. I think I know the root of my problem.

How do I force the strong-typed dataset using an existing schema? For
example, here is the top portion of the XML file I am bringing into the
first dataset:

<?xml version="1.0" encoding="UTF-8" ?>
<IPDRDoc xmlns="http://www.ipdr.org/namespaces/ipdr"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" IPDRRecorderInf o
="qca.nortelnet works.com"
xsi:schemaLocat ion="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>19 70-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset >0</timeZoneOffset>
<callCompletion Code>CC</callCompletionC ode>
<originalDestin ationId></originalDestina tionId>
<hostName>GWC22 @WSCRCAAH00T</hostName>
<subscriberId>S TS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5 360b453206046f6 b626</uniqueCallId>
<ipAddress>199. 173.87.2</ipAddress>
<portNumber>294 4</portNumber>
<seqNum>4200064 </seqNum>
<averagePacketL atency>7</averagePacketLa tency>
<inboundByteCou nt>231040</inboundByteCoun t>
<outboundByteCo unt>230880</outboundByteCou nt>
<inboundPacketC ount>1444</inboundPacketCo unt>
<outboundPacket Count>1443</outboundPacketC ount>
<packetLossPerc entage>0.0</packetLossPerce ntage>
<packetDelayVar iation>0</packetDelayVari ation>
</IPDR>

This is a call record on a voip server. (in case you'd like to know). I
would have thought that by the very nature of XML formats, C# would
check the schema and appropriately set the datatypes in the first
dataset. Then I wouldn't have this casting issue. If you browse out the
IPDR format -

http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd

You'll see that strong typing should already occur. Is there something
I should be adding to my ReadXML method to enforce the schema into the
dataset?

Thanks ahead of time,

Peter

Dave Sexton wrote:
Hi Peter,

Ahh yes. #2 should be disregarded ;)

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you very much. I will attempt what you mention in #3. I think
that is a better method. Also, in #2, those are single left ticks, not
single quotes (the mark under the tilde on the keyboard as opposed to
the quote under the double quotes near ENTER) I use them as many of the
fields I use have whitespace in their column names. I just had not
removed them from this example using a name that does not have
whitespace in the column name.
>
Regards,
>
Peter
>
Dave Sexton wrote:
>Hi Peter,
>>
>1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
>reading the data.
>2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name
>and
>not a string literal: Select("myStrin gField 19.99")
>3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off
>using
>a DataView and setting the RowFilter property.
>>
>--
>Dave Sexton
>>
>"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.
>
My Situation:
>
// I have an .xml file that I am reading into a dataset in the
following code -
>
DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);
>
// I am then attempting to obtain a subset of that dataset to filter
the data as follows -
>
DataSet subSet = ds.Clone();
>
DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");
>
DataTable myTable = subSet.Tables[1];
>
foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);
>
}
>
My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?
>
For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.
>
Thanks ahead of time,
>
Peter Robbins
"Oh, .NET is easy....... if you know how to do it".
>
>
Aug 7 '06 #6
I've used an inferschema readmode, and it's slightly working. I am
having issues iterating the resulting table ; but I'll figure that part
out and report again.

Peter

MurdockSE wrote:
Odd thing, I try to force System.Data.Xml ReadMode.ReadSc hema in the
ReadXML, and the first dataset throws an error that ds.Tables[0] does
not exist. (.NET is making my grey early). urrgh.

Peter

MurdockSE wrote:
Ok. I think I know the root of my problem.

How do I force the strong-typed dataset using an existing schema? For
example, here is the top portion of the XML file I am bringing into the
first dataset:

<?xml version="1.0" encoding="UTF-8" ?>
<IPDRDoc xmlns="http://www.ipdr.org/namespaces/ipdr"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" IPDRRecorderInf o
="qca.nortelnet works.com"
xsi:schemaLocat ion="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>19 70-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset >0</timeZoneOffset>
<callCompletion Code>CC</callCompletionC ode>
<originalDestin ationId></originalDestina tionId>
<hostName>GWC22 @WSCRCAAH00T</hostName>
<subscriberId>S TS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5 360b453206046f6 b626</uniqueCallId>
<ipAddress>199. 173.87.2</ipAddress>
<portNumber>294 4</portNumber>
<seqNum>4200064 </seqNum>
<averagePacketL atency>7</averagePacketLa tency>
<inboundByteCou nt>231040</inboundByteCoun t>
<outboundByteCo unt>230880</outboundByteCou nt>
<inboundPacketC ount>1444</inboundPacketCo unt>
<outboundPacket Count>1443</outboundPacketC ount>
<packetLossPerc entage>0.0</packetLossPerce ntage>
<packetDelayVar iation>0</packetDelayVari ation>
</IPDR>

This is a call record on a voip server. (in case you'd like to know). I
would have thought that by the very nature of XML formats, C# would
check the schema and appropriately set the datatypes in the first
dataset. Then I wouldn't have this casting issue. If you browse out the
IPDR format -

http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd

You'll see that strong typing should already occur. Is there something
I should be adding to my ReadXML method to enforce the schema into the
dataset?

Thanks ahead of time,

Peter

Dave Sexton wrote:
Hi Peter,
>
Ahh yes. #2 should be disregarded ;)
>
--
Dave Sexton
>
"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you very much. I will attempt what you mention in #3. I think
that is a better method. Also, in #2, those are single left ticks, not
single quotes (the mark under the tilde on the keyboard as opposed to
the quote under the double quotes near ENTER) I use them as many of the
fields I use have whitespace in their column names. I just had not
removed them from this example using a name that does not have
whitespace in the column name.

Regards,

Peter

Dave Sexton wrote:
Hi Peter,
>
1. Create a strong-Typed DataSet and define the schema as you want it or add the Typed columns to your DataSet at runtime before
reading the data.
2. 'myStringField' should not be quoted in the string you are passing to the Select method since it's referring to a column name
and
not a string literal: Select("myStrin gField 19.99")
3. Instead of cloning your DataSet, calling Select, looping through the results and filling the clone, you might be better off
using
a DataView and setting the RowFilter property.
>
--
Dave Sexton
>
"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** *************@m 79g2000cwm.goog legroups.com...
Greetings.

My Situation:

// I have an .xml file that I am reading into a dataset in the
following code -

DataSet ds = new DataSet("MyData set");
ds.ReadXml(@"c: \data\"+cmyxmlf ilename);

// I am then attempting to obtain a subset of that dataset to filter
the data as follows -

DataSet subSet = ds.Clone();

DataRow[] copyRows = ds.Tables[1].Select("`myStr ingField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);

}

My Question:
When you read an XML file in this manner, how do you cast the columns
to another type for a SELECT filter expression?

For example, myStringField contains what is actually a "double", but in
string format, as the XMLRead method doesn't allow you to type the
resulting fields. How do I cast in a SELECT filter expression on a
dataset created from XML using ReadXML? I've attempted to cast the type
of the datacolumn in dataset "ds", but it errors out stating I cannot
change it after there is data in the dataset.... well, chicken or egg
flambe? How do I cast the column type prior to the SELECT filter
expression? Or is there a way in the Select method to call upon a cast?
I could not figure out a method that would work.

Thanks ahead of time,

Peter Robbins
"Oh, .NET is easy....... if you know how to do it".
Aug 7 '06 #7
Ok. Inferschema worked. Here is the main portion, and the function it
calls to write to file any span that experiences a packetloss% over 19%
--

DataSet ds = new DataSet("CS2KCa llRecords");
ds.ReadXml(@"c: \data\" + xmlfilename, XmlReadMode.Inf erTypedSchema);

public void WriteAllBadLoss ToFile(DataSet dataset, StreamWriter sw)
{
DataSet subSet = dataset.Clone() ;

subSet.EnforceC onstraints = false;

DataRow[] copyRows =
dataset.Tables[1].Select("`packe tLossPercentage ` 19");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);
}

foreach (DataRow row in myTable.Rows)
{
foreach (Object value in row.ItemArray)
{
if (row.ItemArray. Length 15)
{
sw.WriteLine(ro w.ItemArray[6].ToString() + "
experienced Packet Loss % of: " + row.ItemArray[16].ToString() + "%");
}
}
}
}
Thank you for pointing me in the right direction , or at least
listening while I go nuts figuring out .NET.... :) I'm quoted as
saying ".NET is easy, if you know what you are doing." Unfortunately, I
prove this daily!!! I've never run across a more convoluted yet
powerful construct as ADO.NET :)

Aug 7 '06 #8
Lol. I'm glad you figured it out. I was out eating breakfast. :)

You are correct that you must tell the DataSet to use the schema. However, in this case you are still not creating a strong-Typed
DataSet, but your solution might be fine for your needs.

To create a strong-Typed DataSet you can simply add the .xsd to Visual Studio. That's all you have to do, but there is a potential
problem with strong-Typing the schema. The issue is that schema changes are not automatically reflected in your program. Schema
changes would probably be a breaking change for your application either way so strong-typing might still be the better solution for
you.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr. comwrote in message news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Ok. Inferschema worked. Here is the main portion, and the function it
calls to write to file any span that experiences a packetloss% over 19%
--

DataSet ds = new DataSet("CS2KCa llRecords");
ds.ReadXml(@"c: \data\" + xmlfilename, XmlReadMode.Inf erTypedSchema);

public void WriteAllBadLoss ToFile(DataSet dataset, StreamWriter sw)
{
DataSet subSet = dataset.Clone() ;

subSet.EnforceC onstraints = false;

DataRow[] copyRows =
dataset.Tables[1].Select("`packe tLossPercentage ` 19");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportR ow(copyRow);
}

foreach (DataRow row in myTable.Rows)
{
foreach (Object value in row.ItemArray)
{
if (row.ItemArray. Length 15)
{
sw.WriteLine(ro w.ItemArray[6].ToString() + "
experienced Packet Loss % of: " + row.ItemArray[16].ToString() + "%");
}
}
}
}
Thank you for pointing me in the right direction , or at least
listening while I go nuts figuring out .NET.... :) I'm quoted as
saying ".NET is easy, if you know what you are doing." Unfortunately, I
prove this daily!!! I've never run across a more convoluted yet
powerful construct as ADO.NET :)

Aug 7 '06 #9
Ok. So, I've added a copy of the referenced .xsd as an 'existing item'
to the project as IPDRDoc.xsd. If I remove the
XmlReadMode.Inf erTypedSchema from the ReadXML line, the solution fails
out again when attempting to select any packetLossPerce ntage above
integer 19; stating it cannot compare a string to integer, blah blah.

Is there anything more then adding the file to the solution that I have
to do? I'm sure there is something blatently obvious that is just not
so obvious to me. :)

And I'll leave you alone after this :)

Aug 7 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
547
by: Richard Lee | last post by:
Hi, I have a question when I do a data type cast. the common way when we do a cast, is we know the type we want to cast to, i.e. we want to cast object to string, object xyz = "question"; (string)xyz; now we only have a type object of System.String type
3
5194
by: Dave Byron | last post by:
I am having trouble with DBNull's from my SQL server. I am building/converting a asset web app from Access and my db has nulls on various fields . I have tried searching newsgroups and tried to get some code and some understanding . I am a newbie to vb but my code is below, so can anybody let me know what I am doing wrong to stop this error...
7
2389
by: Robson Carvalho Machado | last post by:
Does anyone knows how to CAST this SQL Response into a MemoryStream ?? When executing below code an error message says "Specified cast is not valid" I need to put this into MemoryStream to use it into imgPhoto Dim imgPhoto As System.Drawing.Image = System.Drawing.Image.FromStream(myStream) Dim dbConn, SQLStmt, dbComm, dbRead, img Dim...
1
6263
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a variable (targetId) in to the usercontrol (IntergySite.aspx) by calling its setter method. Currently, I am using if-then-else and hardcoded the User...
15
2225
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. On a dress rehearsal run through, it failed spectacularly. I was so embarrassed and felt like killing the person that made it fail. However, when it goes live, IT MUST NOT FAIL. The system has...
21
1899
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New DataSet ' Create connection Dim cn As New OleDbConnection With cn .connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _
1
9341
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't know why I cannot perform this casting operation properly. First off, I've got my Typed DataSet named "AuthInfo" declared and I then created an...
7
3668
by: Ryan | last post by:
OK, here's my setup. I have a treeview control that is populated with records from a Product table, and it allows "checking". This is used for my automatic notification system. Say a particular Product is sold, any users who have that boxed checked will get a notification. So my (shortened) database layout is as such: Product Table...
1
5715
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the work manually. I am looking for an automated way. Thank you, Max
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.