
Inserting data from an ADO recordset into a SQL Server table
Hi,
Did you open recordset from one database and trying to insert those
retrieved records into another one?
If yes, then there are several ways to do that
1. Inside loop you would need to build INSERT SQL statement with values from
each record and execute that statement. It is pretty slow way, because you
will execute number of INSERT statements, which is equal to number of
records in a recordset
2. Use XML to transform your recordset to another ADO recordset, which will
*mark* all records inside that recordset as inserted. In that case you could
transfer records from the recordset in one shot using UpdateBatch method.
That method could be slow in case if recordset is very big. If you need
example, then send me e-mail and I will send it to you. It is too big to
post it here
3. Use DTS. I think this is most powerful way to transfer data between
different databases
--
Val Mazur
Microsoft MVP
Quote:
> I'm trying to insert data from an ADO recordset into SQL Server table. I
> understand there are other ways to insert data into tables, i.e. DTS,
> BCP and T-SQL. However, using ADO happens to be the most suitable
> approach in my situation.
> Here is the code that I'm having problems with. Does anyone know how to
> insert data into a SQL Server table from an ADO recordset? Please any
> help would be greatly appreciated. Thanks in advance
> '******************************
> Do While Not oRs.EOF
> Insert molap.dbo.holap
> oRs.MoveNext
> Loop
> '*******************************
> --
> Direct access to this group with http://web2news.com
> http://web2news.com/?microsoft.public.vb.database.ado