problems uploading files to SQL database

I am trying to use a script to uplad word docs to a database using a script I found on the net.  however I keep getting an error msg I can't get past

Microsoft Cursor Engine error '80040e21'

Multiple-step operation generated errors. Check each status value.

/webpublishing/publishing/db-file-to-binary.asp, line 96

The scipt is below

<%@ Language=VBScript %>
<% option explicit %>
<%Response.Expires = 0
Response.CacheControl = "no-cache"%>

'Simple upload to database.
'Suitable for small files - up to 20% of physical server memory
'This sample works with any objDBConection - MDB (JetOLEDB, ODBC)

Server.ScriptTimeout = 240
'Simple upload to database

'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_upload.asp"--><%

Server.ScriptTimeout = 1000
Form.SizeLimit = 1024*1024'1MB

'was the Form successfully received?
Const fsCompletted  = 0

If Form.State = fsCompletted Then 'Completted

  'Open objDBConection to database
Dim objDBCon, objDBRSExample, RS
Dim      strConnectionString
Dim strSQLstmt
strConnectionString = "Provider=SQLOLEDB;Data Source=CVNT158;Initial Catalog=WebPublishing;Integrated Security=SSPI"
'Only opent the objDBConection at the point where you need it!
Set objDBCon = Server.CreateObject("ADODB.Connection")
objDBCon.CursorLocation = 3 'Read/write cursor
objDBCon.Open strConnectionString
Set RS = Server.CreateObject("ADODB.RecordSet")
'Ideally use stored procedure and the ADO Command object - speak to me if you need examples of these however
'to illustrate the objDBConection works ok...
strSQLstmt = "SELECT * FROM WebPublishing.dbo.upload" strSQLstmt, objDBCon, 3 , 3


    'Store extra form info.
    RS("Description") = Form("Description")
    RS("Title") = Form("Title")

    'Add file from source field 'SourceFile' to table field 'Data'
     RS("Data") = Form("SourceFile").ByteArray

            'Some OLEDB drivers (Oracle) requires AppendChunk method
            'Please use next line instead of 'RS("Data") = Form("SourceFile").ByteArray'
   'RS("Data").AppendChunk Form("SourceFile").ByteArray

            'One-block assigning/AppendChunk is suitable for small files
            '(<20% physical server memory). Plese see documentation to store
            '10th megabytes or more in database.

    'Store technical informations
    RS("ContentType") = Form("SourceFile").ContentType
    RS("SourceFileName") = Form("SourceFile").FileName
    RS("DataSize") = Form("SourceFile").Length

    RS("UploadDT") = Now()
      response.write "<Font color=green><br>File " & Form("SourceFile").FileName & " (" & Form("SourceFile").Length & "B) was stored to a database"
  response.write "<br>See Upload table in " & Server.MapPath("upload.mdb") & " database.<br><br></Font>"
ElseIf Form.State > 10 then
  Const fsSizeLimit = &HD
  Select case Form.State
            case fsSizeLimit: response.write  "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
            case else response.write "<br><Font Color=red>Some form error.</Font><br>"
  end Select
End If'Form.State = 0 then

Function GetConnection()
  dim objDBCon, strConnectionString : Set objDBCon = Server.CreateObject("ADODB.Connection")
  GetConnection = "Provider=SQLOLEDB;Data Source=CVNT158;Initial Catalog=WebPublishing;Integrated Security=SSPI"
  set GetConnection = objDBCon
  objDBCon.CursorLocation = 3 'Read/write cursor

end function

function CreateUploadTable(Conn)
  'This function creates upload table for MSSQL 6.5/7.0/2000
  dim SQL
  SQL = SQL & "CREATE TABLE Upload ("
  SQL = SQL & "      UploadID int IDENTITY (1, 1) NOT NULL ,"
  SQL = SQL & "      UploadDT datetime NULL ,"
  SQL = SQL & "      RemoteIP char (15) NULL ,"
  SQL = SQL & "      ContentType char (64) NULL ,"
  SQL = SQL & "      SouceFileName varchar (255) NULL ,"
  SQL = SQL & "      Title varchar (255) NULL ,"
  SQL = SQL & "      Description text NULL ,"
  SQL = SQL & "      Data image NULL "
  SQL = SQL & ")"
  objDBCon.Execute SQL
end function


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <TITLE>ASP huge file upload sample.</TITLE>
 <STYLE TYPE="text/css"><!--TD      {font-family:Arial,Helvetica,sans-serif }TH      {font-family:Arial,Helvetica,sans-serif }TABLE      {font-size:10pt;font-family:Arial,Helvetica,sans-serif }--></STYLE>
 <meta name="robots" content="noindex,nofollow">
<BODY BGColor=white>

<Div style=width:600>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TH noWrap align=left width="20%" bgColor=khaki>&nbsp;<A
      href="">Power ASP
      file upload</A> - upload to database, store file to binary data field&nbsp;</TH>
<TABLE cellSpacing=2 cellPadding=1 width="100%" bgColor=white border=0>
    <TD colSpan=2>
      <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This sample demontrates using
      of Huge-ASP file upload to store files in server-side database.
                  The sample ASP file is running with Microsoft.Jet.OLEDB (MDB) objDBConection, but you can use it
                  with any other SQL server or file drivers (MS SQL server, Oracle, MySQL, FoxPro driver, etc.).

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You can select source file, write some title and description of the file.
Title, description, file name, file size and file contents are stored in server-side database along with current upload time.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Form size limit is <%=Form.SizeLimit%>B (<%=Form.SizeLimit \ 1024 %>kB - you can change it, see source) .

<TABLE cellSpacing=1 cellPadding=3 bordercolor=silver bgcolor=GAINSBORO width="" border=1>
<form method=post ENCTYPE="multipart/form-data">
 <TD Align=Right><input type="submit" Name="Action" value="Upload the file &gt;&gt;"></TD>
 <TD>File to upload</TD>
 <TD><input type="file" name="SourceFile"></TD>
 <TD><input size="60" name="Title" value="Title of the file."></TD>
 <TD><textarea cols="60" rows="8" name="Description">Type description of the file.</textarea></TD>


<HR COLOR=silver Size=1>
<FONT SIZE=1>© 1996 – <%=year(date)%> Antonin Foller, <a href="">Motobit Software</a>, e-mail <A href="" ></A>
<br>To monitor current running uploads/downloads, see <A Href="">IISTracer - IIS real-time monitor</A>.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try removing this line:

objDBCon.CursorLocation = 3 'Read/write cursor
garthpyperAuthor Commented:
now it is not displaying an error, nor is it working
Anthony PerkinsCommented:
The GetChunk/AppendChunk methods have been largely deprecated in favor of the Stream object introduced with ADO v2.5.

Use this code (untested):

Sub AddImage(rs, ByVal FileName)
Dim stm

Set stm = Server.CreateObject("ADODB.Stream")
With stm
  .Type = adTypeBinary
  .LoadFromFile FileName
  'Insert the binary object into the table.
  rs.Fields("Data").Value = .Read
End With
Set stm = Nothing

End Sub

You would call this procedure as follows:

Dim rs

Set rs = Server.CreateObject("ADODB.Recordset")
With rs
   .ActiveConnection = MY_CONN_STRING
   .Source = "SELECT Data FROM WebPublishing.dbo.upload Where 1=0"
   .CursorType = adOpenForwardOnly
   .LockType = adLockOptimistic
   .Open ,,,, adCmdText
   AddImage rs, FileName
End With
Set rs = Nothing

As you can see it is a lot simpler.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.