Hello All and Thank You for your time,
I am stuck on this exception handleing error. The problem is that when
I run my application the application works perfect but sometimes, I get
this error. I do not know where it is causing it but my guess would be
something with the function below. Any help would be greatfull, as this
would be a learning experience for me.
For this example: swTitle.Text = "AutoCAD 2004"
After the user selects the product from a listbox, a datagrid is binded
to an arraylist which is field with all of the <EmployeeName>
associated with that product.
So I have split the EmployeeName up into four fields (FirstName, MI,
LastName, Email). and each field will be a column in the datagrid.
Function Task:
**********************
1) Read XML file
2) Use XPath to find a particular node
3) Query the node for fields and print out the fields in datagrid
XML File Example:
**********************
<EMPProductType>
<ProductType>AutoCAD 2004</ProductType>
<ManagerEMail>de********@email.com</ManagerEMail>
<EmployeeName>Joe,,Alexander,jo***********@email.c om</EmployeeName>
<EmployeeName>Joe,,Allen,jo*******@email.com</EmployeeName>
<EmployeeName>Harold,,Anderson,ha*************@ema il.com</EmployeeName>
<EmployeeName>Kent,,Berner,ke*********@email.com </EmployeeName>
<EmployeeName>Tommy,,Childers,to************@email .com</EmployeeName>
</EMPProductType>
Function:
**********************
void GetUserList()
{
XmlDocument doc = new XmlDocument();
doc.Load("http://dpi948.delta.com/dtedmprod:/Field_Operations/ETAM/SFT/Software.xml");
//XmlNode sw;
XmlNodeList sw;
XmlNode root = doc.DocumentElement;
// SEARCH XML FILE
string t = "'" + swTitle.Text + "'";
sw=root.SelectNodes("//EMPProductType[ProductType=" + t + "
]/EmployeeName");
total = sw.Count;
// RETURN DATA FROM XPATH
if(sw != null)
{
for (int i=0; i < sw.Count; i++)
{
len = sw[i].InnerXml.Length;
ind = sw[i].InnerXml.IndexOf(',');
fn = sw[i].InnerXml.Substring(0, ind);
ind = ind + 1;
len = len - ind;
s1 = sw[i].InnerXml.Substring(ind,len);
ind = s1.IndexOf(',');
mi = s1.Substring(0, ind);
if(mi == "")
{
mi = "x";
}
ind = ind + 1;
len = len - ind;
s1 = s1.Substring(ind, len);
ind = s1.IndexOf(',');
ln = s1.Substring(0, ind);
ind = ind + 1;
len = len - ind;
ue = s1.Substring(ind, len);
ul.Add (new user(fn, mi, ln, ue));
temp = temp + " " + fn + " " + mi + " " + ln + " " + ue + "<br>";
}
usedCount.Text = total.ToString();
myDataGrid.DataSource=ul;
myDataGrid.DataBind();
}
} 2 3141
Just a guess, but it is most likely the fact that most of your people have no
middle name. From the error, you are probably erroring out trying to submit
to a database. If so, you will have to set the default for that parameter to
null and not set it when the string is empty.
if(txtMiddleName.Text.ToString().Length >= 1)
{
//Set Parameter
}
else
{
//Do nothing
}
You do not need the else, but it illustrates the point.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"ma**********@gmail.com" wrote: Hello All and Thank You for your time, I am stuck on this exception handleing error. The problem is that when I run my application the application works perfect but sometimes, I get this error. I do not know where it is causing it but my guess would be something with the function below. Any help would be greatfull, as this would be a learning experience for me.
For this example: swTitle.Text = "AutoCAD 2004" After the user selects the product from a listbox, a datagrid is binded to an arraylist which is field with all of the <EmployeeName> associated with that product. So I have split the EmployeeName up into four fields (FirstName, MI, LastName, Email). and each field will be a column in the datagrid.
Function Task: ********************** 1) Read XML file 2) Use XPath to find a particular node 3) Query the node for fields and print out the fields in datagrid
XML File Example: ********************** <EMPProductType> <ProductType>AutoCAD 2004</ProductType> <ManagerEMail>de********@email.com</ManagerEMail> <EmployeeName>Joe,,Alexander,jo***********@email.c om</EmployeeName> <EmployeeName>Joe,,Allen,jo*******@email.com</EmployeeName> <EmployeeName>Harold,,Anderson,ha*************@ema il.com</EmployeeName>
<EmployeeName>Kent,,Berner,ke*********@email.com </EmployeeName> <EmployeeName>Tommy,,Childers,to************@email .com</EmployeeName> </EMPProductType>
Function: ********************** void GetUserList() {
XmlDocument doc = new XmlDocument(); doc.Load("http://dpi948.delta.com/dtedmprod:/Field_Operations/ETAM/SFT/Software.xml");
//XmlNode sw; XmlNodeList sw; XmlNode root = doc.DocumentElement;
// SEARCH XML FILE string t = "'" + swTitle.Text + "'"; sw=root.SelectNodes("//EMPProductType[ProductType=" + t + " ]/EmployeeName"); total = sw.Count; // RETURN DATA FROM XPATH if(sw != null) {
for (int i=0; i < sw.Count; i++) { len = sw[i].InnerXml.Length; ind = sw[i].InnerXml.IndexOf(','); fn = sw[i].InnerXml.Substring(0, ind); ind = ind + 1; len = len - ind; s1 = sw[i].InnerXml.Substring(ind,len); ind = s1.IndexOf(','); mi = s1.Substring(0, ind); if(mi == "") { mi = "x"; } ind = ind + 1; len = len - ind; s1 = s1.Substring(ind, len); ind = s1.IndexOf(','); ln = s1.Substring(0, ind); ind = ind + 1; len = len - ind; ue = s1.Substring(ind, len);
ul.Add (new user(fn, mi, ln, ue));
temp = temp + " " + fn + " " + mi + " " + ln + " " + ue + "<br>";
} usedCount.Text = total.ToString(); myDataGrid.DataSource=ul; myDataGrid.DataBind(); }
}
Thanks Cowboy,
But am I not doing that here:
mi = s1.Substring(0, ind);
if(mi == "")
{
mi = "x";
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Flynn |
last post by:
hi all
i'm going to be quick i have an assignment due which i have no idea how to
do. i work full time so i dont have the time to learn it and its due date
has crept up on me ..
As follows:...
|
by: xunling |
last post by:
i have a question about answering ..... this topic is "need help"
what do i have to write at te topic line, !after i have klicked the
"answer message" button
ive tried many possibilities,...
|
by: Scott Holland |
last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also
AS/400 from NT Server
-- I am experienced in ORACLE and a novice at DB2. What tools would
be the equivalent of Net*8 or...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte...
|
by: bryan |
last post by:
I have a situation that's pretty delicate that I need some help on.
I've been stumped for awhile I just need some advice on the best
possible solution.
The problem:
I have a site I'm making...
|
by: vinod.bhavnani |
last post by:
Hello all,
I need desperate help
Here is the problem:
My problem today is with multidimensional arrays.
Lets say i have an array A this is a 4 dimensional
static array.
|
by: pamelafluente |
last post by:
I am beginning aspNet, I know well win apps.
Need a simple and schematic code example to start work.
This is what I need to accomplish:
----------------------
Given button and a TextBox on a...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: jhaydon |
last post by:
First of all, I'm not a CSS expert. If I was, I wouldn't need to be posting for help here. Secondly, I have been doing web design for several years, just not css. Thirdly, I need help and hope...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |