Results 1 to 6 of 6

Thread: [2005] Improve efficiency of insert statements

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    [2005] Improve efficiency of insert statements

    Hi guys,
    I was wondering whether there was a more efficient way to do numerous inserts into an oracle database.
    At the moment i am doing:

    Open Oracle Connection
    for each row in a dgv
    create insert command using cells from a row
    execute command
    go to next row
    close oracle connection when inserted all rows

    Now sometimes i only around 100 rows to insert, but at other time i have over 20,000, which is done quite slowly.
    So i was wondering whether there were any more efficient ways to perform a large number of insert statements?

    Any help appreciated

  2. #2
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] Improve efficiency of insert statements

    Create a dataset, add the table to the dataset. Make all the changes to the table and send that back through the adapter as a bulk transaction...
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Improve efficiency of insert statements

    Quote Originally Posted by warrenayen
    Create a dataset, add the table to the dataset. Make all the changes to the table and send that back through the adapter as a bulk transaction...
    The Update() method of a dataadapter actually goes thru the dataset/datatable and looks for a change in row state. If it sees it, it performs the appropriate action (insert, update, or delete) for the row... So the bottom line is, it is still doing one row at a time.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [2005] Improve efficiency of insert statements

    Create a dataset, add the table to the dataset. Make all the changes to the table and send that back through the adapter as a bulk transaction...
    This is what i am originally doing.
    Sorry i think i should've given more information. I import from an excel worksheet into my datagridview and then, using insert statements, go through each row and put everything into a table in oracle. I have supplied my code if anybody wants to see exactly what i am doing. The code to import from excel to my datagridview is in the Main form and the code to insert into oracle is in the createStore form.
    Attached Files Attached Files

  5. #5
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: [2005] Improve efficiency of insert statements

    I don't know about Oracle, but I know SQL Server will take in an XML document and then parse that.

    When I have had over 20 inserts that need to be done at one time, I create an XML document on the local machine and then pass that in as a parameter for a stored procedure and the stored procedure parses it and inserts the data. This has helped me to reduce a great amount of network traffic.
    My.Settings.Signature = String.Empty

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [2005] Improve efficiency of insert statements

    I dont really know enough on the subject to attempt to try that method as it'll probably cause more errors and problems than necessary....thanx newayz tho!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width