sql server - "Write Conflict" error appears in single user database -
running ms access 2010 front end under citrix against sql server 2008r2 backend.
i've got form that's been working quite time. code behind 1 button has started generating 'write conflict' error. happened few days ago, , after several hours pouring on unchanged code (confirmed online text comparison tool), , having programmer here on it, solution grab production version of front end , start reapplying changes.
it's been running great 2 days, , error happened again. changing code, on different form. need go through processes on form in order test other form.
here code generating write conflict:
private sub btnstart_click() dim auditid string dim userstatus string dim submitpeerrev boolean dim prpercent single dim examineraudits integer dim reviewaudits integer dim rs dao.recordset dim username string dim sqlstring string on error goto error_handler userstatus = funuserlookup("status", raw:=true) 'get percentage/whole number 'this percentage should submitted review if isnull(dlookup("itemvalue", "tblconfig", "item = '" & userstatus & "'")) form_frmmenu.msgboxtimed ("your user id not configured correctly within ap_audit db." & vbcrlf & _ "you cannot start audit." & vbcrlf & _ "please contact manager set correctly.") exit sub else prpercent = csng(dlookup("itemvalue", "tblconfig", "item = '" & userstatus & "'")) end if username = funuserlookup("examiner") 'get total audits done sqlstring = "select count(*) " & _ " tblauditatt " & _ " examiner = '" & username & "'" & _ " , month(amonth) = " & month(now()) & _ " , year(amonth) = " & year(now()) set rs = currentdb.openrecordset(sqlstring, dbopendynaset) examineraudits = rs.fields("[a]") 'get peer-reviewed audits done sqlstring = "select count(*) " & _ " tblauditatt " & _ " traineeexaminer = '" & username & "'" & _ " , month(amonth) = " & month(now()) & _ " , year(amonth) = " & year(now()) set rs = currentdb.openrecordset(sqlstring, dbopendynaset) reviewaudits = rs.fields("[a]") set rs = nothing if dlookup("started", "tblauditatt", "attaudit_id = " & me.attaudit_id) form_frmmenu.msgboxtimed "this audit started else. select new one." me.requery exit sub end if 'username = funuserlookup("examiner") if reviewaudits = 0 'ensure 1 review - prevents divide 0 me.traineeexaminer = username me.traineeexaminer.visible = true me.traineeexaminer.top = 2280 me.examiner.visible = false elseif examineraudits = 0 , prpercent < 1 'ensure 1 non-review if < 100% peer-review me.examiner = username me.traineeexaminer.visible = false me.examiner.visible = true elseif examineraudits / (examineraudits + reviewaudits) > 0.99999999 - prpercent 'the tiny fraction needed because 0 > 0 = false & 100% trainees straight submit me.traineeexaminer = username me.traineeexaminer.visible = true me.traineeexaminer.top = 2280 me.examiner.visible = false else me.examiner = username me.traineeexaminer.visible = false me.examiner.visible = true end if me.startdate = format(form_frmmenu.getsqltime, "mm/dd/yyyy") me.started = true me.dirty = false form_frmmenu.execsp "audit_attauditstart", 120, false, "@auditid", adinteger, me.attaudit_id 'this failing, reasons yet unknown, continue if hasn't if nz(dlookup("attaudit_a", "tblauditatt_a", "attaudit_id = " & me.attaudit_id), 0) > 0 me.btnstartend.enabled = true me.btnstartend.setfocus me.btnstart.enabled = false me.frmattaudit_a_sub.requery setsubformview 'now know type of audit & have questions, set proper view else me.traineeexaminer = "" me.examiner = "" me.startdate = "" me.started = false me.dirty = false sqlstring = form_frmmenu.logerror(0, "audit did not start properly", "user defined", "frmattaudit_a.btnstart_click", "stored procedure failed insert records") end if exit sub error_handler: if form_frmmenu.logerror(err.number, err.description, err.source, "frmattaudit_a.btnstart_click", sqlstring) = "next" resume next else resume end if end sub
notes:
- i'm running on our dev server , i'm 1 using these tables
- i added timestamp column, , didn't seem make difference
- i've move
me.dirty = false
code after each bound form field change , doesn't help - the solution production code , reapply changes hand.
- you can see there's another oddity that's causing insert query fail. don't know if it's happened since changing calling stored procedure, failing when there
docmd.runsql
statement - i received suggestion in post disable hooking in citrix environment, since might messing things up, our people won't that.
any other thoughts or suggestions on how resolve this? don't have time redo work every couple of days when access decides puke.
if underlying sql server table has bit fields null values, may cause write conflict error access when linked through odbc sql server. has access first converting null bit value 0 , trying apply changes made , causing write conflict.
in case, solved have new bit fields default 0 , replacing null values 0 on existing fields.
Comments
Post a Comment