473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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 3911
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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.

My Situation:

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

DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.

My Situation:

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

DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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.googlegro ups.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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.

My Situation:

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

DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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" IPDRRecorderInfo
="qca.nortelnetworks.com"
xsi:schemaLocation="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>1970-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset>0</timeZoneOffset>
<callCompletionCode>CC</callCompletionCode>
<originalDestinationId></originalDestinationId>
<hostName>GWC22@WSCRCAAH00T</hostName>
<subscriberId>STS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5360b453206046f6b626</uniqueCallId>
<ipAddress>199.173.87.2</ipAddress>
<portNumber>2944</portNumber>
<seqNum>4200064</seqNum>
<averagePacketLatency>7</averagePacketLatency>
<inboundByteCount>231040</inboundByteCount>
<outboundByteCount>230880</outboundByteCount>
<inboundPacketCount>1444</inboundPacketCount>
<outboundPacketCount>1443</outboundPacketCount>
<packetLossPercentage>0.0</packetLossPercentage>
<packetDelayVariation>0</packetDelayVariation>
</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.googlegro ups.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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.

My Situation:

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

DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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.XmlReadMode.ReadSchema 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" IPDRRecorderInfo
="qca.nortelnetworks.com"
xsi:schemaLocation="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>1970-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset>0</timeZoneOffset>
<callCompletionCode>CC</callCompletionCode>
<originalDestinationId></originalDestinationId>
<hostName>GWC22@WSCRCAAH00T</hostName>
<subscriberId>STS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5360b453206046f6b626</uniqueCallId>
<ipAddress>199.173.87.2</ipAddress>
<portNumber>2944</portNumber>
<seqNum>4200064</seqNum>
<averagePacketLatency>7</averagePacketLatency>
<inboundByteCount>231040</inboundByteCount>
<outboundByteCount>230880</outboundByteCount>
<inboundPacketCount>1444</inboundPacketCount>
<outboundPacketCount>1443</outboundPacketCount>
<packetLossPercentage>0.0</packetLossPercentage>
<packetDelayVariation>0</packetDelayVariation>
</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.googlegro ups.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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.
>
My Situation:
>
// I have an .xml file that I am reading into a dataset in the
following code -
>
DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);
>
// 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("`myStringField` 19.99");
>
DataTable myTable = subSet.Tables[1];
>
foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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.XmlReadMode.ReadSchema 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" IPDRRecorderInfo
="qca.nortelnetworks.com"
xsi:schemaLocation="http://www.ipdr.org/namespaces/IPDR/IPDRDoc3.1.xsd"
version="3.1">
<IPDR>
<StartTime>1970-01-01T00:00:00Z</StartTime>
<EndTime>1970-01-01T00:00:00Z</EndTime>
<timeZoneOffset>0</timeZoneOffset>
<callCompletionCode>CC</callCompletionCode>
<originalDestinationId></originalDestinationId>
<hostName>GWC22@WSCRCAAH00T</hostName>
<subscriberId>STS/2/0/3/VT15/3/4/4/12@HNLL0800</subscriberId>
<uniqueCallId>5360b453206046f6b626</uniqueCallId>
<ipAddress>199.173.87.2</ipAddress>
<portNumber>2944</portNumber>
<seqNum>4200064</seqNum>
<averagePacketLatency>7</averagePacketLatency>
<inboundByteCount>231040</inboundByteCount>
<outboundByteCount>230880</outboundByteCount>
<inboundPacketCount>1444</inboundPacketCount>
<outboundPacketCount>1443</outboundPacketCount>
<packetLossPercentage>0.0</packetLossPercentage>
<packetDelayVariation>0</packetDelayVariation>
</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.googlegro ups.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("myStringField 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*********************@m79g2000cwm.googlegro ups.com...
Greetings.

My Situation:

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

DataSet ds = new DataSet("MyDataset");
ds.ReadXml(@"c:\data\"+cmyxmlfilename);

// 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("`myStringField` 19.99");

DataTable myTable = subSet.Tables[1];

foreach (DataRow copyRow in copyRows)
{
myTable.ImportRow(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("CS2KCallRecords");
ds.ReadXml(@"c:\data\" + xmlfilename, XmlReadMode.InferTypedSchema);

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

subSet.EnforceConstraints = false;

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

DataTable myTable = subSet.Tables[1];

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

foreach (DataRow row in myTable.Rows)
{
foreach (Object value in row.ItemArray)
{
if (row.ItemArray.Length 15)
{
sw.WriteLine(row.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.googlegr oups.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("CS2KCallRecords");
ds.ReadXml(@"c:\data\" + xmlfilename, XmlReadMode.InferTypedSchema);

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

subSet.EnforceConstraints = false;

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

DataTable myTable = subSet.Tables[1];

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

foreach (DataRow row in myTable.Rows)
{
foreach (Object value in row.ItemArray)
{
if (row.ItemArray.Length 15)
{
sw.WriteLine(row.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.InferTypedSchema from the ReadXML line, the solution fails
out again when attempting to select any packetLossPercentage 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
Hi,

I could not find the definition of packetLossPercentage in the .xsd you referenced in a previous post. You might need to find an
updated schema.

If you don't have an updated schema, open your .xsd in VS.NET and select the packetLossPercentage column if it exists. In the
property grid manually change the DataType property to System.Double. If it doesn't exist, as I would expect, add it. The default
type will be System.String. Now the error makes perfect sense. After all, the column was added at runtime and you got an error
about invalid comparison between a string and an integer.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr.comwrote in message news:11**********************@p79g2000cwp.googlegr oups.com...
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.InferTypedSchema from the ReadXML line, the solution fails
out again when attempting to select any packetLossPercentage 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 #11
Agreed. I may just create my own from scratch. I have a case open with
the vendor as the referenced xsd does not match the format of the ipdrs
in the file. (also in the real one that I download and ungzip, the URL
is wrong too -- I had corrected it before posting the example). As it
stands, the inferedschema xmlreadmode is working as desired for this
simple project. As this is not a commercial product - and hence, likely
no additional parsing will be necessary, It will suffice for now. I
will correct it when I can get a more valid schema to work from.

Thanks for all your help ; I'll let you all know how this turns out.

Peter Robbins

Dave Sexton wrote:
Hi,

I could not find the definition of packetLossPercentage in the .xsd you referenced in a previous post. You might need to find an
updated schema.

If you don't have an updated schema, open your .xsd in VS.NET and select the packetLossPercentage column if it exists. In the
property grid manually change the DataType property to System.Double. If it doesn't exist, as I would expect, add it. The default
type will be System.String. Now the error makes perfect sense. After all, the column was added at runtime and you got an error
about invalid comparison between a string and an integer.

--
Dave Sexton

"MurdockSE" <mu*****@nc.rr.comwrote in message news:11**********************@p79g2000cwp.googlegr oups.com...
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.InferTypedSchema from the ReadXML line, the solution fails
out again when attempting to select any packetLossPercentage 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 8 '06 #12

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

Similar topics

4
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";...
3
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...
7
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...
1
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...
15
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...
21
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...
1
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...
7
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.