Bill,
ADO and ADO.NET (and all of its predecessors after DB-Library) are QUERY
interfaces, not designed for bulk operations. It's a waste of time and
resources to try to use the System.Data classes to import more than a few
rows of data.
Can you explain why it's a waste of time? Looking at what I've found so
far, that approach would probably take me, personally, about hundredth of
the time requires to figure out the other stuff. And that takes into
consideration the fact that I've been so far unable to find a simple
example showing how to add records to a database using the System.Data
classes.
When it's time to import data into SQL Server, the fastest (by an order of
magnitude or more) is to use the TDS bulk copy approach. This is exposed
in a number of ways including:
a.. The BCP commandline utility.
b.. TSQL BulkCopy operations
c.. DTS/SSIS scripts
d.. ADO.NET SqlBulkCopy method.
All of these techniques can import data from anything that can be read by
a .NET data provider, an OLE DB data provider, and ODBC driver or your own
custom-written data provider that exposes a DataReader. This means other
database tables, flat files, text files, delimited files--almost anything.
These routines can import millions of rows in no time. Some Oracle
customers buy SQL Server just to get SSIS.
Okay...
I guess TDS stands for something but "tds bulk copy" brings up one a
single result on Google, and that wasn't much help.
Let's try this: Can you tell me which of these is available with what I
have (VS2005 and SQL Server Management Studio Express)? Also, any spec of
details on using any of these would be a tremendous help. Maybe even a
link of some sort.
And I have your book "Hitchhiker's Guide to Visual Studio and SQL Server."
Am I understanding correctly that this doesn't step through what I want to
do anywhere? Or how about an example that shows how to add records to a
database from C# (with no controls, Access, or anything else other than C#
and SQL)?
My latest book details how to use SqlBulkCopy. BOL shows how to do the
rest. I'll be happy to show it to you if you come to one of my sessions
this week at DevConnections in Vegas or at my workshop in Vancouver BC on
the 26th (see
www.devweek.com for availability).
<<<<<
Sounds good, but I'll be far from Vegas at that time.
Thanks.