A
Aaron
Why am I getting the following error:
"An unhandled exception of type 'System.FormatException' occured in
mscorlib.dll"
from this code:
string[] medicationList = new string[14];
double[] parenteralValues = new double[14];
double[] oralValues = new double[14];
private void GetValues()
{
String xmlFile = "Program Files\\C-Tools\\pnmd.xml";
int arrayCount = 0;
XmlTextReader xmlTr = new XmlTextReader(xmlFile);
while (xmlTr.Read())
{
switch(xmlTr.Name)
{
case "Drug":
if (xmlTr.NodeType == XmlNodeType.Element)
medicationList[arrayCount] = xmlTr.ReadString();
break;
case "Parenteral":
if (xmlTr.NodeType == XmlNodeType.Element)
parenteralValues[arrayCount] =
System.Convert.ToDouble(xmlTr.ReadString());
break;
case "Oral":
if (xmlTr.NodeType == XmlNodeType.Element)
oralValues[arrayCount] = System.Convert.ToDouble(xmlTr.ReadString());
break;
default:
break;
}
arrayCount += 1;
}
xmlTr.Close();
}
Here's my xml structure:
<?xml version="1.0" encoding="utf-8" ?>
<Pain_Medications>
<Medications>
<Drug>Codeine</Drug>
<Parenteral>130.00</Parenteral>
<Oral>200.00</Oral>
<Comment>Codeine is usually combined with Tylenol or aspirin, and that is
the limiting factor in the dosage of this drug.
</Medications>
</Pain_Medications>
Also, if someone could tell my how to make the arrays dynamic since I won't
be having a static amount of records, the above 14 was just for testing
purposes.
Thanks
"An unhandled exception of type 'System.FormatException' occured in
mscorlib.dll"
from this code:
string[] medicationList = new string[14];
double[] parenteralValues = new double[14];
double[] oralValues = new double[14];
private void GetValues()
{
String xmlFile = "Program Files\\C-Tools\\pnmd.xml";
int arrayCount = 0;
XmlTextReader xmlTr = new XmlTextReader(xmlFile);
while (xmlTr.Read())
{
switch(xmlTr.Name)
{
case "Drug":
if (xmlTr.NodeType == XmlNodeType.Element)
medicationList[arrayCount] = xmlTr.ReadString();
break;
case "Parenteral":
if (xmlTr.NodeType == XmlNodeType.Element)
parenteralValues[arrayCount] =
System.Convert.ToDouble(xmlTr.ReadString());
break;
case "Oral":
if (xmlTr.NodeType == XmlNodeType.Element)
oralValues[arrayCount] = System.Convert.ToDouble(xmlTr.ReadString());
break;
default:
break;
}
arrayCount += 1;
}
xmlTr.Close();
}
Here's my xml structure:
<?xml version="1.0" encoding="utf-8" ?>
<Pain_Medications>
<Medications>
<Drug>Codeine</Drug>
<Parenteral>130.00</Parenteral>
<Oral>200.00</Oral>
<Comment>Codeine is usually combined with Tylenol or aspirin, and that is
the limiting factor in the dosage of this drug.
</Medications>
</Pain_Medications>
Also, if someone could tell my how to make the arrays dynamic since I won't
be having a static amount of records, the above 14 was just for testing
purposes.
Thanks