Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB6 : Is there any way to insert bulk ResultSet rows into a database, instead of using the loop.
Posted

1 solution

What i understood from your question is that you want to builk insert data in some table in the database. If this is what you want then yes you can do that. You could build an xml that contain the data that you want to insert and pass it to a stored procedure. In that stored procedure you can insert rows in one go using XML suported inserts. Hopes this could solve your problem.
 
Share this answer
 
Comments
Sams13 8-Jul-13 4:01am    
I am asking if there are a better way to insert data from resultSet into sql table rather than using the looping

Do While rs.EOF = False
cmdCommand.CommandText = "INSERT INTO tblAccount(FULL_NAME) VALUES ( '" & rs.Fields(0).Value & "')"
cmdCommand.Execute (cmdCommand)
rs.MoveNext
Loop
_Asif_ 8-Jul-13 4:14am    
To my understanding there is no bulk insert support command object. You can do something like this.

var xml as string
Do While rs.EOF = False
xmlstring = xmlstring + "<full_name value="" & rs.Fields(0).Value & "">"
rs.MoveNext
Loop

cmdCommand.CommandText = "SP_BULK_INSERT"
'Pass xml parameter to SP_BULK_INSERT
cmdCommand.Execute (cmdCommand)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900