RE: SqlDataReader performance
- From: v-wywang@xxxxxxxxxxxxxxxxxxxx (WenYuan Wang)
- Date: Mon, 11 Dec 2006 06:38:26 GMT
Hi Jan,
First of all, I'd like to confirm my understanding of your issue.
According to your description, I understand that you want to know why it
will take a long time to execute the statement "string keyvalue =
dr[keyname].ToString()".
If I misunderstand anything here, please don't hesitate to correct me.
The first thing we have to do is to check which mode you have set when you
do the test.
There will be a performance issue when we use DEBUG mode.
If we want to get more performance, we should change the mode to RELEASE.
Second, as Shawn said, GetValue would call GetOrdinal first, if we're
looping through a large rowset GetOrdinal might be called every single
time. Instead, only call it once.
Try this instead:
dr = cmd.ExecuteReader();
string keyvalue = "";
int ordinal = dr.GetOrdinal(keyname);
while(dr.Read())
{
keyvalue = dr[ordinal].ToString();
...
}
Last but not least, I'm afraid I don't think it will take a long time to
execute the statement "string keyvalue = dr[keyname].ToString()". It seems
like "dr.Read()" is time consuming.
Would you mind telling us which version of ADO.net your program run on?
I'll perform more research on it.
If there is anything unclear, please feel free to reply me here. We will
follow up.
I'm glad to work with you.
Sincerely,
WenYuan
.
- Follow-Ups:
- RE: SqlDataReader performance
- From: Jan
- RE: SqlDataReader performance
- From: Jan
- RE: SqlDataReader performance
- Prev by Date: RE: DataColumn.DateTimeMode property - How to use it?
- Next by Date: Delete a row from Excel via ADO.NET
- Previous by thread: Re: SqlDataReader performance
- Next by thread: RE: SqlDataReader performance
- Index(es):