AddNew record to visual Foxpro using ASP

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.

Who is Participating?
pabearsterAuthor Commented:
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
Wayne BarronAuthor, Web DeveloperCommented:
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.
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.
Olaf DoschkeSoftware DeveloperCommented:
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

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.

All Courses

From novice to tech pro — start learning today.