Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP OLE-DB driver fails with AddNew
Message
 
 
To
05/10/2005 07:31:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01056072
Message ID:
01056300
Views:
11
Thank you Cetin. The problem was with null fields, as you predicted. There were a couple of fields in the new record that I was not explicitly initializing, and this was causing the problem. I didn't even know about the "Set Null Off" command (thank you!).

Another problem solved. Thank goodness for the UT community or I'd never get anywhere.

>>Excuse me while I express my DISGUST and FRUSTRATION at how poorly Microsoft has implemented error reporting with their OLE-DB / ODBC technology. It's impossible to know where a problem is with messages like "Multiple-step operation generated errors. Check each status value."
>>
>>I'm getting an error with the RS.Update statement below (vbscript from an ASP module):
>>  with RS
>>   .activeconnection=DBCONNECTION
>>   .cursortype = adOpenStatic
>>   .cursorlocation = adUseClient
>>   .locktype = adLockOptimistic
>>   .Source = "select * from users"
>>   .open
>>  end with
>>RS.AddNew
>>RS.FIELDS("F1")="XXX"
>>etc...
>>RS.UpDate
>>...and then I get that maddening "Multiple-step operation generated errors. " message and no idea why. Can somebody please tell me just how to use ADO to add new records to a VFP table. I don't think security is an issue here. "Everyone" has full access to folders and files. Thanks very much.
>
>Mark,
>This is almost an exact copy of my reply to your email:
>
>Mark,
>I think it is security. All users include IUSR_machinename account? Everyone doesn’t include IUSR as far as I know. Check if you enabled the folder for web access. Also explicitly check security for your files (happened to me when I thought it was sufficient to do it at folder level –should be- but after some failures I saw that the data files didn’t have necessary rights for web user).
>
>If security is set right the second cause is null fields. Fields might be set as ‘NOT NULL’ but a new record sends nulls for fields that are not populated. To workaround it first execute a ‘set null off’ command so VFP automatically provides ‘blank’ values for fields that are not populated.
>
>Here is a sample code I know that works if security is adjusted (not using AddNew here but I know that one works too):
>
><%
>cSQLSelect = "select * from employee where !isnull(birth_date) and !isnull(hire_date)"
>cSQLInsert = "insert into employee (emp_id,First_name,last_name,hire_date) " &_
>     " values ('CBASOZ','Cetin','Basoz',date())"
>cSQLUpdate = "update testdata!employee " &_
>   "set " &_
>   "Birth_date = {^1961/01/19}, "   & _
>   "Title = 'FoxyClasses Developer' " & _
>   "where emp_id = 'CBASOZ'"
>
>    dbpath = Server.MapPath("data")
>    set oConnection = Server.CreateObject( "adodb.connection" )
>    with oConnection
>       .ConnectionString = "Provider=VFPOLEDB;data source=" & dbpath & "\testdata.dbc"
>       .Open
>       .Errors.Clear
>       .Execute( "set null off" )
>       .Execute( cSQLInsert )
>       .Execute( cSQLUpdate )
>       Set rs = .Execute( cSQLSelect )
>    end with
>
>    ' Check results
>    Response.Write("<TABLE border='1'><TR><TD>Emp Id</TD>" & _
>    "<TD>First Name</TD><TD>Last Name</TD><TD>Title</TD><TD>Born</TD><TD>Hired</TD></TR>" )
>    while not rs.eof
>            Response.Write("<TR>")
>            Response.Write("<TD>" & rs.Fields("emp_id").value & "</TD>")
>            Response.Write("<TD>" & rs.Fields("first_name").value & "</TD>")
>            Response.Write("<TD>" & rs.Fields("last_name").value & "</TD>")
>            Response.Write("<TD>" & rs.Fields("title").value & "</TD>")
>            Response.Write("<TD>" & DatePart("yyyy",rs.Fields("birth_date").value) & "/" & _
>              DatePart("m",rs.Fields("birth_date").value) & "/" & _
>              DatePart("d",rs.Fields("birth_date").value) & "</TD>")
>            Response.Write("<TD>" & rs.Fields("hire_date").value & "</TD>")
>            Response.Write("</TR>")
>            rs.MoveNext
>    wend
>    Response.Write("</TABLE><BR/>")
>'           cStoredProcCall = "myStoredProc('ReverseMe')"
>'            set rsc = oconnection.execute( cStoredProcCall )
>'            response.write(rsc.fields(0).value)
>
>    oConnection.Close
>    set oConnection = nothing
>  
>
>This is from another snippet that’s working:
>
>lrs.AddNew
>lrs.Fields("emp_id").Value = "CBTEST"
>lrs.Fields("First_Name").Value = "cetin"
>lrs.Fields("Last_Name").Value = "basoz"
>lrs.Fields("hire_date").Value = #2004/01/13#
>lrs.UpdateBatch
>
>Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform