AddNew record to visual Foxpro using ASP

Posted on 2009-02-19
Last Modified: 2013-12-24
I cannot add a simple text value to a new record.  When I add a new record, a stored procedure is tripped to supply a new ID number.  ID is used as the primary key in the table CASHOUT  Removing the stored procedure from the database has no effect on the error received

Dim objConn, rsAns, Connstr
Set objConn =  Server.CreateObject("ADODB.connection")
ConnStr= "Provider=vfpoledb;Data Source=d:\websites\pump\mail\contact.dbc"
Set rsAns= server.CreateObject("adodb.recordset")
rsAns.Open "SELECT * FROM cashout WHERE id=0", objconn,3,3,1         ' this does not return a record id=0 is an impossible result


rsAns.fields("shift")="day"        'fields is defined as character field size is 10


The update command triggers this error message

Microsoft Cursor Engine error '80040e21'

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

Question by:pabearster
    LVL 30

    Expert Comment

    by:Wayne Barron
    to start off with. I have never seen it written out like this:
    rsAns.Open "SELECT * FROM cashout WHERE id=0", objconn,3,3,1

    I have always seen it written out like this:
    mysql =  "SELECT * FROM cashout WHERE id=0"
    rsAns.Open mysql, objconn,3,3,1
    (I could be way of base on that one, as it is Foxpro, and i use access/sql server)

    The issue with the [Update] Error [Microsoft Cursor Engine error '80040e21']
    Make sure that you are not trying to insert a string that is too long for a field.

    Your Field length is: 50
    Your string that you are trying to pass is: 60 characters in length.

    Hope this helps.
    LVL 28

    Expert Comment

    If the above is your actual code, then I miss a line where you open the connection.
    So basically you are working with a closed connection, which of course does not work.
    LVL 29

    Expert Comment

    by:Olaf Doschke
    You are opening the RS with adOpenStatic.

    See here for the possible Parameter values for the CursorType parameter of RS.Open():

    try this:
    objConn.Open ConnStr
    rsAns.Open "SELECT * FROM cashout WHERE id=0", objconn,1,3,1

    Open in new window


    Accepted Solution

    It turns out that my code is correct.  I traced the problem down to the table itself.  I had to allow for NULL values to be inserted to the table.  When I modified the table structure to allow NULL values in a field, everything worked as it should have

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure ( It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
    The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: :…
    The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now