473,397 Members | 2,068 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,397 software developers and data experts.

method returning dataset question

I have written a method that is meant to return a dataset from a SQL
Server table (or not if there is nothing there to return). My app
regularly times out and crashes at this point and I don't know why.
Here is my method :

public DBResult Get_Prepay_Dataset(out DataSet dsPrepay, string strCUG,
string strSubcugPrepayQuery, DateTime dtmStartDatePrepayQuery, DateTime
dtmEndDatePrepayQuery)
{
DBResult dbrGetPrepayDataset;
string strGetPrepayDataset;

if (strSubcugPrepayQuery != "")
{
strGetPrepayDataset = "SELECT INCEPTTIME, STARTTIME, ENDTIME,
RTRIM(ODN) AS 'ODN', RTRIM(OOLI) AS 'OOLI' FROM RSP_LOG WITH (NOLOCK)
WHERE CUG = '" + strCUG + "' AND SUB_CUG = '" + strSubcugPrepayQuery +
"' AND STARTTIME BETWEEN '" + dtmStartDatePrepayQuery + "' AND '" +
dtmEndDatePrepayQuery + "'";
}
else
{
strGetPrepayDataset = "SELECT INCEPTTIME, STARTTIME, ENDTIME,
RTRIM(ODN) AS 'ODN', RTRIM(OOLI) AS 'OOLI' FROM RSP_LOG WITH (NOLOCK)
WHERE CUG = '" + strCUG + "' AND STARTTIME BETWEEN '" +
dtmStartDatePrepayQuery + "' AND '" + dtmEndDatePrepayQuery + "'";
}

SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectHomelinkTest"
]);
dsPrepay = new DataSet();

try
{
SqlDataAdapter objAdapter = new SqlDataAdapter(strGetPrepayDataset,
objConnection);

objAdapter.Fill(dsPrepay, "tblPrepay");

int intCount = dsPrepay.Tables["tblPrepay"].Rows.Count;

if (intCount > 0)
{
dbrGetPrepayDataset = DBResult.Valid;
}
else
{
dbrGetPrepayDataset = DBResult.Invalid;
}
}
catch
{
dsPrepay = null;
dbrGetPrepayDataset = DBResult.Error;
}

objConnection.Close();

return dbrGetPrepayDataset;
}

Can anybody find something I am doing wrong in my code? Any help would
be really appreciated.
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
3 1212
Hi,

The only part where it can be get stuck is in the Fill method , how big is
your DB and how long this query takes?

Does this happens with only you accesing or when more than one page is being
served?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mike P" <mr*@telcoelectronics.co.uk> wrote in message
news:eW*************@TK2MSFTNGP10.phx.gbl...
I have written a method that is meant to return a dataset from a SQL
Server table (or not if there is nothing there to return). My app
regularly times out and crashes at this point and I don't know why.
Here is my method :

public DBResult Get_Prepay_Dataset(out DataSet dsPrepay, string strCUG,
string strSubcugPrepayQuery, DateTime dtmStartDatePrepayQuery, DateTime
dtmEndDatePrepayQuery)
{
DBResult dbrGetPrepayDataset;
string strGetPrepayDataset;

if (strSubcugPrepayQuery != "")
{
strGetPrepayDataset = "SELECT INCEPTTIME, STARTTIME, ENDTIME,
RTRIM(ODN) AS 'ODN', RTRIM(OOLI) AS 'OOLI' FROM RSP_LOG WITH (NOLOCK)
WHERE CUG = '" + strCUG + "' AND SUB_CUG = '" + strSubcugPrepayQuery +
"' AND STARTTIME BETWEEN '" + dtmStartDatePrepayQuery + "' AND '" +
dtmEndDatePrepayQuery + "'";
}
else
{
strGetPrepayDataset = "SELECT INCEPTTIME, STARTTIME, ENDTIME,
RTRIM(ODN) AS 'ODN', RTRIM(OOLI) AS 'OOLI' FROM RSP_LOG WITH (NOLOCK)
WHERE CUG = '" + strCUG + "' AND STARTTIME BETWEEN '" +
dtmStartDatePrepayQuery + "' AND '" + dtmEndDatePrepayQuery + "'";
}

SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectHomelinkTest"
]);
dsPrepay = new DataSet();

try
{
SqlDataAdapter objAdapter = new SqlDataAdapter(strGetPrepayDataset,
objConnection);

objAdapter.Fill(dsPrepay, "tblPrepay");

int intCount = dsPrepay.Tables["tblPrepay"].Rows.Count;

if (intCount > 0)
{
dbrGetPrepayDataset = DBResult.Valid;
}
else
{
dbrGetPrepayDataset = DBResult.Invalid;
}
}
catch
{
dsPrepay = null;
dbrGetPrepayDataset = DBResult.Error;
}

objConnection.Close();

return dbrGetPrepayDataset;
}

Can anybody find something I am doing wrong in my code? Any help would
be really appreciated.
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Hi,

The table being accessed has approx 17,000 records. At any one time
there may be 0-20 users accessing it via my code.
Regards,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Does it occur when only one user is accesing it?

Maybe the bottleneck is in the DB access, if the DB server is slow, or too
much data is returned, did you try it without the hint?

If the DB does not change a lot maybe a better idea is to keep it in the
cache and refresh it from time to time.

are you reloading the data on each postback ?

you should look in a way to improve the access to the dB.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mike P" <mr*@telcoelectronics.co.uk> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
Hi,

The table being accessed has approx 17,000 records. At any one time
there may be 0-20 users accessing it via my code.
Regards,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4

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

Similar topics

10
by: Steven Blair | last post by:
Hi, Quick overview of the problem: public bool Something( out DataSet ds ) { bool ret=false; try {
2
by: martinharvey via DotNetMonster.com | last post by:
I realise this is a beginners question but i would be grateful for some help Untill now i have been using Datareaders for example; Public Class Catalog Public Shared Function SP_GetBB() As...
1
by: Ed. | last post by:
I have an ArrayList of objects of class C. I need to return the list via a web method. What's the best approach? If I convert the list into a DataSet I could return the DataSet, but how would I...
0
by: Alan | last post by:
I have successfully created DLL and registered. And run in webpage using VBScript. However, I have a method returning a typed dataset, do I need to do anything on DLL so that the VBScript can hold...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
2
by: David++ | last post by:
Hello list, I have built a project in VS2005 which includes a Web Service Web Site. On this server there is a Database. I have used the DataSet designer to link to this database and VS2005 has...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
5
by: Eric Fortin | last post by:
I have a disconnected handheld device that I want to send the results of the day to a database through a web service (on an intranet) What's the best method to do this? XML? Tab...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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
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.