2012-06-12 106 views
0

我有一个使用SQLServer 2008 R2作为数据库的Access应用程序。Microsoft access db错误编辑记录

当我尝试更新的一条记录我得到这个错误:只有在这个特定的记录(以及其他一些)

"3179 the microsoft Jet databse engine stopped the process because you and another user are attempting to change the same data at the same time"

此错误追加每次我尝试更新时间追加。 应用程序(和DB)运行为单个用户和我没有在同一时间运行的线程更新相同的记录

enter image description here

我得到每台机器上这个错误我尝试所以不应该与SQLServer相关。

编辑
我有尝试更新SQL Server中的记录directy并没有什么问题,这是确定的updare。

我发现问题是当我从Microsoft访问更新四个文本字段(es.Note)之一。

当我运行下面的脚本我只有一个特定的记录(Cod_stabile = 6600015)与其他记录没有 问题的错误。更新其他字段没关系,错误只存在于文本字段中。

Dim rs as DAO.Recordset 
Dim db As DAO.Database 
Set db = CurrentDb 

. . . 

StrSql = "SELECT St_Stabili.* FROM St_Stabili WHERE (St_Stabili.Cod_Stabile='6600015') ;" 
Set rs = db.OpenRecordset(StrSql) 
rs.Edit 
rs!Note = '-' 
rs.update <- error 


. . . 

StrSql = "SELECT St_Stabili.* FROM St_Stabili WHERE (St_Stabili.Cod_Stabile='6600016') ;" 
Set rs = db.OpenRecordset(StrSql) 
rs.Edit 
rs!Note = '-' 
rs.update <- OK! 

非常感谢您

+0

当你说你没有一个线程在运行,你确定你是不是在代码或者其他的形式或窗体打开记录?当您尝试在链接表中更新此记录时,是否收到错误消息? – Fionnuala

回答

0

我解决了不断变化的用于更新文本字段的方法:

Dim UpdCommand As ADODB.command 
    Set UpdCommand = New ADODB.command 
    With UpdCommand 
     .ActiveConnection = CurrentProject.Connection 
     .CommandType = adCmdText 
     .CommandText = "UPDATE St_Stabili SET NoteStabile= ?" _ 
             & ",NoteGenerali = ?" _ 
             & ",NoteConteggio = ?" _ 
             & ",NoteAmministratori = ?" _ 
       & " WHERE St_Stabili.Cod_Stabile = ?;" 

     .Parameters.Append .CreateParameter("NotaSt", adVarChar, adParamInput, 300, Me!NoteStabile_x) 
     .Parameters.Append .CreateParameter("NotaGen", adVarChar, adParamInput, 300, Me!NoteGenerali_x) 
     .Parameters.Append .CreateParameter("NotaCon", adVarChar, adParamInput, 300, Me!NoteConteggio_x) 
     .Parameters.Append .CreateParameter("NotaAmm", adVarChar, adParamInput, 300, Me!NoteAmministratori_x) 
     .Parameters.Append .CreateParameter("Cod_Stabile", adVarChar, adParamInput, 15, Me!Cod_Stabile_x) 
    End With 

UpdCommand.Execute 
0

检查,看看你的SQL Server表有更新基于您的更新记录的触发器。这在MS Access中显示为另一用户更新了记录。如果你的SQL Server表格特别在触发器中有TIMESTAMP,请小心。