473,388 Members | 1,207 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,388 software developers and data experts.

Speeding up a DataGrid with XML

I have a datagrid that gets a SQL query returned containing one column that
is XML. While I build the datagrid I have to split and parse the XML to get
the information that I want for each row. The query will return 350 rows in
about 1 second, but when the page builds the dataGrid it takes one minute.
Can anyone point me in a direction that could help to speed this up? This is
in ASP.NET and C# for a web application. The code is below.

Thanks in advance,
Matt
private void BindGrid(System.DateTime beginDateTime, System.DateTime
endDateTime, int partnerID)
{
try
{
CareVu.WebServices.PartnerServices partner = new
CareVu.WebServices.PartnerServices();
// ********************
DataSet dsPRejects = new DataSet();
dsPRejects.Clear();

dsPRejects = partner.GetPartnerRejectedClaims(beginDateTime,
endDateTime, partnerID, CheckBox1.Checked);

/// Build the dataTable for the DataGrid
DataTable rejectsTable = new DataTable();
rejectsTable.Clear();

DataColumn c0 = new DataColumn("TransactionID");
DataColumn c1 = new DataColumn("Patient Name");
DataColumn c2 = new DataColumn("Destination");
DataColumn c3 = new DataColumn("Trans Type");
DataColumn c4 = new DataColumn("Batch");
DataColumn c5 = new DataColumn("Date");

string xmlString = "//NewDataSet/Table";

DataColumn c6 = new DataColumn("Reason for Rejection");
DataColumn c7 = new DataColumn("Remove");
DataColumn c8 = new DataColumn("SourcePartnerID");

rejectsTable.Columns.Add(c0);
rejectsTable.Columns.Add(c1);
rejectsTable.Columns.Add(c2);
rejectsTable.Columns.Add(c3);
rejectsTable.Columns.Add(c4);
rejectsTable.Columns.Add(c5);
rejectsTable.Columns.Add(c6);
rejectsTable.Columns.Add(c7);
rejectsTable.Columns.Add(c8);

int num=0;
DataRow errorRow;
foreach(DataRow r in dsPRejects.Tables[0].Rows)
{
errorRow = rejectsTable.NewRow();

TranID = r["TransactionID"].ToString();
errorRow["TransactionID"] = r["TransactionID"].ToString();
errorRow["Trans Type"] = r["Trans Type"].ToString();
errorRow["Batch"] = r["Batch"].ToString();
errorRow["Date"] = r["Date"].ToString();
errorRow["Remove"] = @"<A href=partnerclaimrejects.aspx?removeid=" +
TranID + @">" + "Remove" + @"</A>";

num++;
// *******************************
Rejection(xmlString, dsPRejects, num, errorRow, TranID);

errorRow["Patient Name"] = r["Patient Name"].ToString();
errorRow["Destination"] = r["Destination"].ToString();
errorRow["SourcePartnerID"] = r["SourcePartnerID"].ToString();
rejectsTable.Rows.Add(errorRow);
}

rejectsTable.AcceptChanges();
DataView dv = new DataView(rejectsTable);

partnersGrd.AutoGenerateColumns = false;
// ********************
lblReportType.Text = "Report of Rejected Claims";
lblReportType.Visible = true;
Session["ProClaims"] = dv;

partnersGrd.DataSource = dv;
partnersGrd.DataBind();
dsPRejects.Dispose();
}
catch(Exception exc)

Microsoft.ApplicationBlocks.ExceptionManagement.Ex ceptionManager.Publish(exc);
Response.Redirect(Request.ApplicationPath + @"/error.aspx");
}
}

private void Rejection(string xmlString, DataSet ds, int num, DataRow
errorRow, string tranId)
{
try
{
string PayorError = "";
Ack = "";
errRow = "";
Session["ProResponse"] = "";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(ds.GetXml());

XmlNodeList elemList;
elemList =
xmlDoc.GetElementsByTagName("Reason_x0020_for_x002 0_Rejection");

int x = num-1;

// Get the Local error message
System.IO.StringReader sr = new
System.IO.StringReader(elemList[x].InnerText.ToString());
XmlTextReader xTxt = new XmlTextReader(sr);
XmlReader xRdr = xTxt;
do
{
xRdr.Read();
}
while(!xRdr.EOF && xRdr.Name != "ErrorRecord");
if(!xRdr.EOF)
{
xRdr.MoveToAttribute("error_description");
try
{
Ack = xRdr.Value.ToString();
}
catch
{
}
}
else
{
// Pull the Response Error Message
DataSet dsResponse = new DataSet();
CareVu.WebServices.TransactionServices txn = new
CareVu.WebServices.TransactionServices();
if(Session["ProResponse"].ToString() == "")
{
dsResponse = txn.GetRejectedPayorResponses(Int32.Parse(tranId)) ;
}
else
{
dsResponse = (DataSet) Session["ProResponse"];
}

int i = 1;
foreach(DataRow p in dsResponse.Tables[0].Rows)
{
System.IO.StringReader srOrig2 = new
System.IO.StringReader(dsResponse.GetXml());
XmlTextReader xOrig2 = new XmlTextReader(srOrig2);
XmlReader xrOrig2 = xOrig2;
string acknowledgment2 = "";
do
{
xrOrig2.Read();
}
while(!xrOrig2.EOF && xrOrig2.Name !=
"Reason_x0020_for_x0020_Rejection");
if(!xrOrig2.EOF)
{
acknowledgment2 = xrOrig2.ReadString();
}

if(p["Reason for Rejection"].ToString() != "")
{
Ack = p["Reason for Rejection"].ToString();
errorRow["Reason for Rejection"] = "";

System.IO.StringReader sr2 = new System.IO.StringReader(Ack);
XmlTextReader xTxt2 = new XmlTextReader(sr2);
XmlReader xRdr2 = xTxt2;
do
{
xRdr2.Read();
}
while(!xRdr2.EOF && xRdr2.Name != "ClaimStatusMessage");
if(!xRdr2.EOF)
{
try
{
Ack = " -- Msg " + i++ + " -- " + xRdr2.ReadString();
}
catch
{
}
PayorError = PayorError + Ack.Replace("...", " ");
}
}
}

Session["ProResponse"] = dsResponse;
dsResponse.Clear();
dsResponse.Dispose();
}
if(PayorError != "")
{
errRow = PayorError;
}
else if(Ack != "")
{
errRow = Ack;
}
else
{
errRow = "Payor response message is not available!";
}
errorRow["Reason for Rejection"] = errRow;
}
catch(Exception exc)
{
Microsoft.ApplicationBlocks.ExceptionManagement.Ex ceptionManager.Publish(exc);
Response.Redirect(Request.ApplicationPath + @"/error.aspx");
}
}
Nov 19 '05 #1
0 1122

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

Similar topics

4
by: Snyke | last post by:
Hi. I have a command line script which works really fine, the only problem is that it take *really* long for the first output to be printed on screen. Since I also get some HTTP headers I'm...
12
by: dvumani | last post by:
I have C code which computes the row sums of a matrix, divide each element of each row with the row sum and then compute the column sum of the resulting matrix. Is there a way I can speed up the...
9
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields...
10
by: Timothy Graves | last post by:
I have a quick (pun intended) question for the guru's out there. I have a piece of code where I am validating the input of chancters into a cell in a datagrid. I am using the keypressed event to...
2
by: Robert Wilkens | last post by:
Ok... This may be the wrong forum, but it's the first place I'm trying. I'm new to C# and just implemented the 3-tier Distributed application from Chapter 1 (the first walkthrough) in the...
2
by: OHM | last post by:
I was wondering about this topic and although I accept that different situations call for different solutions, but wondered are there any other solutions and whether has anyone carried out a...
5
by: RobinAG | last post by:
Hello, I just split my database into front and back end. My front end users are experiencing really slow opening of forms. I've searched online for help speeding up forms, but I'm not sure what...
10
by: ags5406 | last post by:
I've created an application that downloads data daily from a secure web site and stores that data in an Access database. Then there are different options for allowing the user to do keyword and...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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,...
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...

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.