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

Parsing Issues

I have a program that runs as a windows service waking up at predefined
intervals to send out mails. Each mail is based on a template with tags to
replace with database data from that specific row (mail merge type of
operation). Every so often the parsing is only half-done; but I’ve seen the
parsing work fully some times. I was thinking it could be some kind of a
memory problem (there are a lot of string manipulations in the code) but
checked to find the server did have good amount of free memory available. Has
anyone come across such a problem? If so, was this problem circumvented and
how?

I am adding below code snippet of how I am accomplishing the same.
try
{
SqlConnection con = dbc.Connection;
SqlConnection con1 = dbc.Connection;
SqlCommand com = new SqlCommand("<db select for the master row>", con);
SqlCommand com1;
SqlDataReader sdr = com.ExecuteReader();

while (sdr.Read())
{
string temp = shipmailtemplate;

temp = temp.Replace("<#tagidentifier>", sdr.GetSqlString(3).ToString());
….<more replacements such as above)

com1 = new SqlCommand("<db select for the detail row>", con1);

SqlDataReader sdr1 = com1.ExecuteReader();
bool isrow = false;
while (sdr1.Read())
{
isrow = true;
iter = iter.Replace("<#tagidentifier>", sdr1.GetSqlString(0).ToString());
….<more replacements such as above)
}
sdr1.Close();

if (isrow)
{
<send mails out>
}
}
sdr.Close();
con1.Close();
con.Close();
}
catch (Exception ex)
{
WriteError(ex.ToString());
}

Nov 16 '05 #1
3 1201
Badri,

How does the "dbc.Connection" property behave? Does it always return
the same connection, or does it create a new connection each time it
is called? If it always returns the same connection, then this code
may be the source of your problems:

SqlConnection con = dbc.Connection;
SqlConnection con1 = dbc.Connection;

If dbc.Connection always returns the same connection, then con and
con1 both point to the same connection. SqlDataReader requires
exclusive access to a connection until it is closed.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
Chris - Thx for your response; the dbc.Connection always returns a new
connection. The curious thing about this is that it sometimes is able to
parse even 250 mails successfully but other times it even fails with just 60
to 70 parsings. And out of these failures, 99% it does not retrieve the
detail records (the second SQL / inner loop) in spite of the bool variable
"isrow" being checked prior to sending out the mails and no exception is
thrown either.

thx

"Chris R. Timmons" wrote:
Badri,

How does the "dbc.Connection" property behave? Does it always return
the same connection, or does it create a new connection each time it
is called? If it always returns the same connection, then this code
may be the source of your problems:

SqlConnection con = dbc.Connection;
SqlConnection con1 = dbc.Connection;

If dbc.Connection always returns the same connection, then con and
con1 both point to the same connection. SqlDataReader requires
exclusive access to a connection until it is closed.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 16 '05 #3
"=?Utf-8?B?QmFkcmk=?=" <Ba***@discussions.microsoft.com> wrote in
news:53**********************************@microsof t.com:
Chris - Thx for your response; the dbc.Connection always returns
a new connection. The curious thing about this is that it
sometimes is able to parse even 250 mails successfully but other
times it even fails with just 60 to 70 parsings. And out of
these failures, 99% it does not retrieve the detail records (the
second SQL / inner loop) in spite of the bool variable "isrow"
being checked prior to sending out the mails and no exception is
thrown either.


Badri,

The only other thing I can think of is the connection may be timing
out. You could try using DataSets instead of data readers. That
would reduce the time a connection remains open.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #4

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

Similar topics

6
by: Walter Dörwald | last post by:
Hello all! I'm trying to parse broken HTML with several Python tools. Unfortunately none of them work 100% reliable. Problems are e.g. nested comments, bare "&" in URLs and "<" in text (e.g....
9
by: Thomas W | last post by:
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed...
3
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
9
by: wardy | last post by:
I'm trying to undestand the impact of using content negotiation when rendering my Web pages to various different browsers as I would like to use the XHTML Strict DOCTYPE declaration. Reading the...
1
by: sp | last post by:
i have an xml file (an rss file) <?xml version="1.0" ?> <rss version="2.0"> <channel> <title>CodeGuru.com</title> <link>http://www.codeguru.com/</link> <description>The number one developer...
0
by: cactus | last post by:
Eight years after the invention of XML, DOM and SAX, despite their respective issues, are still the mainstays of application developers. So is it the end of road for XML parsing innovation? ...
0
by: Jarod_24 | last post by:
I've tried the WebBrowser in the System.Windows.Forms namespace, but it dosen't work when you instanciate an object from a class. It needs a Form to live in to work. My application allready has...
4
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. I am working with Plimus for licensing my software. I can communicate with the server and I'm getting responses in XML....
1
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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
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 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.