You are here: Re: Insert into a table recursively « MsSQL Server « IT news, forums, messages
Re: Insert into a table recursively

Posted by Erland Sommarskog on 05/19/06 11:49

Robert Ludig (schwertfischtrombose@gmx.de) writes:
> I am using C# and ADO.NET to acess the database. I have a Hashtable
> that contains all the Steps wich should be insterted (100-10000). I
> suppose it is a bad idea to create one big instertion command (as
> string) and the do a OleDbCommand.ExecuteNonQuery() ? How can I insert
> all at once in a clever way by using ADO.NET ?

That's not bad at all. Most of all it is effecient. If you insert rows
one by one, there will be many network roundtrips.

The one thing that is messy is to pass all the parameters. Of course,
you can build an SQL statement with the parameters expanded, but generally
you should stick to parameterised commands. It's not that difficult to
handle. You build the SQL statement in a loop, and add the SELECT for one
step, and then you add the parameters for that step as well.


The alternative is build an XML document and pass this to a stored
procedure, and then unpack the XML with OPENXML.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация