inserting array into SQL DB using ASP and ADO

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default inserting array into SQL DB using ASP and ADO

    I would like to know how I can improve performance in inserting data
    from an XLS sheet into SQL using a Stored Proc.

    Steps:

    1) Upload XLS file to server
    2) SELECT sheet from XLS file and inserting it into an array
    3) Do a FOR loop through the XLS import array and executes a
    parameterized connection to the SQL server using a new
    ADODB.Connection & ADODB.Recordset for each record.

    It works, but is it the best way of doing this? The results are
    horrible in my opinion. The act of importing almost 1,100 records
    from the XLS file takes about 8 minutes--- refreshing SQL Enterprise
    Manager shows a guessed average of about 5 records every 2 seconds.

    Anyone enlighten me? I will eventually be moving my code over to .NET
    but not for another >3 months as our team builds up knowledge on it.

    ---- CODE SNIP ----
    Set connTemp = Server.CreateObject("ADODB.Connection")
    connTemp.ConnectionTimeout = Session("connTemp_ConnectionTimeout")
    connTemp.CommandTimeout = Session("connTemp_CommandTimeout")
    connTemp.Open DSNTemp

    For I = LBound(Session("dataExcel"),2) to
    UBound(Session("dataExcel"),2)
    Set cmdTemp = Server.CreateObject("ADODB.Command")
    Set rsObj = Server.CreateObject("ADODB.Recordset")
    cmdTemp.CommandText = "sp_Insert_XLS"
    cmdTemp.CommandType = adCmdStoredProc

    ..... extra parameters snipped for space ...

    Set cmdTemp.ActiveConnection = connTemp
    Set tmpParam = cmdTemp.CreateParameter("Web", adVarChar,adParamInput,
    255, Session("dataExcel")(15,I))
    cmdTemp.Parameters.Append tmpParam

    ..... extra parameters snipped for space ...

    set rsObj = cmdTemp.Execute()
    set rsObj = nothing
    Set cmdTemp = Nothing
    Next
    set connTemp = Nothing
    ---- CODE SNIP ----


    Thanks much in advance!

    Christopher Lemon
    Christopher Guest

  2. Similar Questions and Discussions

    1. #40385 [NEW]: inserting references to an array
      From: viqq at gazeta dot pl Operating system: Linux ubuntu 2.6.15-27-386 PHP version: 5.2.0 PHP Bug Type: Variables related...
    2. [newbie]saving and reading array of associative array
      i'm looking for examples of saving to file and reading back an array of associative array, in a ruby like way. saying i have something like : ...
    3. array data matches but array created in loop doesn't work
      I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' =>...
    4. #24897 [Com]: array_multisort() will reindex the array but not if array length is 1
      ID: 24897 Comment by: franklin_se at hotmail dot com Reported By: chro at sokrates dot uio dot no Status: ...
    5. #24897 [Opn->Asn]: array_multisort() will reindex the array but not if array length is 1
      ID: 24897 Updated by: sniper@php.net Reported By: chro at sokrates dot uio dot no -Status: Open +Status: ...
  3. #2

    Default Re: inserting array into SQL DB using ASP and ADO

    Why not use SQL Server's builtin Import functionality (Data Transformation
    Services). It's bound to be much faster than anything you could code
    together. Go to [url]www.sqldts.com[/url] for details. They have a few tutorials there.

    Bob Barrows
    Christopher wrote:
    > I would like to know how I can improve performance in inserting data
    > from an XLS sheet into SQL using a Stored Proc.
    >

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: inserting array into SQL DB using ASP and ADO

    On 20 Jul 2004 06:57:40 -0700, [email]clemon@apwa.net[/email] (Christopher) wrote:
    >I would like to know how I can improve performance in inserting data
    >from an XLS sheet into SQL using a Stored Proc.
    >
    >Steps:
    >
    >1) Upload XLS file to server
    >2) SELECT sheet from XLS file and inserting it into an array
    >3) Do a FOR loop through the XLS import array and executes a
    >parameterized connection to the SQL server using a new
    >ADODB.Connection & ADODB.Recordset for each record.
    >
    >It works, but is it the best way of doing this?
    I wouldn't think so. SQL's DTS is made for this job, can be scheduled
    and should be almost instantaneous compared to looping through a
    record set. Look in BOL for Data Transformation, or just walk through
    the wizard, it's pretty simple to configure it.

    Jeff
    Jeff Cochran Guest

  5. #4

    Default Re: inserting array into SQL DB using ASP and ADO

    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message news:<O0fvAjmbEHA.368@TK2MSFTNGP10.phx.gbl>...
    > Why not use SQL Server's builtin Import functionality (Data Transformation
    > Services). It's bound to be much faster than anything you could code
    > together. Go to [url]www.sqldts.com[/url] for details. They have a few tutorials there.
    >
    > Bob Barrows
    > Christopher wrote:
    > > I would like to know how I can improve performance in inserting data
    > > from an XLS sheet into SQL using a Stored Proc.
    > >
    Yeah I could, but I would rather not because the end result is an
    employee doing the work and making it as seamless as possible. I had
    been digging around a it and found that if I do a INTO statement I can
    tunnel my data from the Excel Spreadsheet right into SQL Server
    without having do do the Array & FOR loop. But of course I am having
    difficulties with that ;) Our servers are not linked, but I am trying
    to do a DSN call and route it through there...

    The Web Sever AND the SQL server are seperate boxes too.

    Any thoughts on how to accomplish this?



    Phfft.
    Christopher Guest

  6. #5

    Default Re: inserting array into SQL DB using ASP and ADO

    Christopher wrote:
    > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:<O0fvAjmbEHA.368@TK2MSFTNGP10.phx.gbl>...
    >> Why not use SQL Server's builtin Import functionality (Data
    >> Transformation
    >> Services). It's bound to be much faster than anything you could code
    >> together. Go to [url]www.sqldts.com[/url] for details. They have a few
    >> tutorials there.
    >>
    >> Bob Barrows
    >> Christopher wrote:
    >>> I would like to know how I can improve performance in inserting data
    >>> from an XLS sheet into SQL using a Stored Proc.
    >>>
    >
    > Yeah I could, but I would rather not because the end result is an
    > employee doing the work
    ??

    DTS can be automated. Go to the site and check out the diffierent methods
    for executing a DTS package (including from ASP).

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  7. #6

    Default Re: inserting array into SQL DB using ASP and ADO

    Thanks for both of your replies. Although I didn't want to use DTS I
    can see that it seems this is the best route.

    What annoyes me is I was trying to do an INTO using a OPENDATASOURCE
    connecting to the XLS file and I kept getting errors and no matter
    what KB's I do it still doesn't work.

    Thanks for taking the time to reply!

    [email]jeff.nospam@zina.com[/email] (Jeff Cochran) wrote in message news:<40fe4ab3.183385534@msnews.microsoft.com>...
    > On 20 Jul 2004 06:57:40 -0700, [email]clemon@apwa.net[/email] (Christopher) wrote:
    >
    > >I would like to know how I can improve performance in inserting data
    > >from an XLS sheet into SQL using a Stored Proc.
    > >
    > >Steps:
    > >
    > >1) Upload XLS file to server
    > >2) SELECT sheet from XLS file and inserting it into an array
    > >3) Do a FOR loop through the XLS import array and executes a
    > >parameterized connection to the SQL server using a new
    > >ADODB.Connection & ADODB.Recordset for each record.
    > >
    > >It works, but is it the best way of doing this?
    >
    > I wouldn't think so. SQL's DTS is made for this job, can be scheduled
    > and should be almost instantaneous compared to looping through a
    > record set. Look in BOL for Data Transformation, or just walk through
    > the wizard, it's pretty simple to configure it.
    >
    > Jeff
    Christopher Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139