• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

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.CursorLocation=3
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.AddNew

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

rsAns.Update
rsAns.Close

The update command triggers this error message

Microsoft Cursor Engine error '80040e21'

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


postcash2.txt
0
pabearster
Asked:
pabearster
1 Solution
 
Wayne BarronCommented:
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.

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

Hope this helps.
Carrzkiss
0
 
sybeCommented:
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.
0
 
Olaf DoschkeSoftware DeveloperCommented:
You are opening the RS with adOpenStatic.

See here for the possible Parameter values for the CursorType parameter of RS.Open():
http://msdn.microsoft.com/en-us/library/ms681771(VS.85).aspx

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

Open in new window

0
 
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
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now