Re: DataTable.Load()



That is what Wen was saying: You should not see any open and close. I would
take this further and say "I would be absolutely shocked to see any new
connections", as the under-the-hood operations are not transparent and do
not bubble up to the connection level.

What Bill was talking about is the way SQL Server handles things, which is
not something the average developer would ever get into. What Bill was
stating is that communication will be in blocks. This does not mean a new
connection opening each time, as the Reader is a firehose cursor. As you run
through it and get past what is cached, you will get another request.

In normal operations, you run through a Reader like so:

while(Reader.Read()
{
}

This operation takes a fraction of a second to complete, at least in most
applications, as you do not want to leave a connection dangling.

Now, back to DataTable.Load(). It is still using a Reader, underneath the
hood. As it loads, the data is loaded in blocks. As more info is needed,
more blocks of data are requested, until complete. This is transparent to
the user, as the entire Load() operation should normally be in milliseconds.
Sure, you can load a boatload of data, but, other than reporting, there are
few reasons to do that.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Scott M." <smar@xxxxxxxxxxxxx> wrote in message
news:%23xGM%23$EgIHA.5296@xxxxxxxxxxxxxxxxxxxxxxx
Why would you see the connection opening and closing on the server during
a DataReader's read operations? Wouldn't it just stay open until .NET
asks for it to be closed?


""Wen Yuan Wang [MSFT]"" <v-wywang@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:MmwG%23aDgIHA.6844@xxxxxxxxxxxxxxxxxxxxxxxxx
Thanks for William and Cor's reply.

Hello Scott,

In my opinion, there is only one round-trip in Load method. If you use
profile to trace what happens on SQL server, I believe you won't find any
connection open/close event when loading.

But, on ado.net side, .net runtime get data from DB server by cache side
blocks.
The implement of Load method should be something like blow:
While (DataReader.read())
{Table.Rows[row][column]=DataReader.getFiled(int);}

Hope this helps. Please feel free to let me know if you have more
concern.
We are glad to assist you.
Have a great day,
Best regards,

Wen Yuan
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.





.



Relevant Pages

  • Re: Transaction Error on None-Transaction Query
    ... Create database connection ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Word Searching XML
    ... which will be somewhat interactive and can not expected to load ... we are trying to search XML node and its ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: Error while connecting to SQL 2005 from ASP.Net 2.0
    ... If so, as theerrormessage indicate, theSQLServer2005 currently disallow remote connection to it. ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: remote database connection in asp.net program
    ... it is a common connection error ... How to configure SQL Server 2005 to allow remote connections ... Microsoft Online Community Support ... nature are best handled working with a dedicated Microsoft Support Engineer ...
    (microsoft.public.sqlserver.connect)
  • Re: format of the initialization string does not conform to specification starting at index 0
    ... instead of being able to browse to the location of the Access Database File ... When I tried to enter the connection string manually, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)

Quantcast