需要更新的数据记录在数据表中只有一条,而且数据表中也定义了主键,奇怪为什么会出现这种提示呢?
实时错误 ‘-2147467259(80004005)’:键列信息不足或不正确。更新影响到多行
代码如下:
Dim mrc1 As ADODB.Recordset
txtsql = "select csflag ,tpflag from FNo0006 where dyleibieID=0 "
Set mrc1 = ExecuteSQL(txtsql)
If Combo4.Text = "黑白" Then
mrc1.Fields("csflag").Value = "0"
Else
mrc1.Fields("csflag").Value = "1"
End If
If Check6.Value = 1 Then
mrc1.Fields("tpflag").Value = True
ElseIf Check6.Value = 0 Then
mrc1.Fields("tpflag").Value = False
End If
mrc1.Update
mrc1.Close
实时错误 ‘-2147467259(80004005)’:键列信息不足或不正确。更新影响到多行
代码如下:
Dim mrc1 As ADODB.Recordset
txtsql = "select csflag ,tpflag from FNo0006 where dyleibieID=0 "
Set mrc1 = ExecuteSQL(txtsql)
If Combo4.Text = "黑白" Then
mrc1.Fields("csflag").Value = "0"
Else
mrc1.Fields("csflag").Value = "1"
End If
If Check6.Value = 1 Then
mrc1.Fields("tpflag").Value = True
ElseIf Check6.Value = 0 Then
mrc1.Fields("tpflag").Value = False
End If
mrc1.Update
mrc1.Close
可能因为你ExecuteSQL后mrc1包含了多行,你没有定位就直接修改值导致的。
怎样解决"键列信息不足或不正确。更新影响到多行"这种提示信息呢?
Dim mrc1 As ADODB.Recordset
If Combo1.Text = "黑白" And Check1.Value = 1 Then
txtsql = "update FNo0006打印设定信息 set csflag='0 ',tpflag=True where dyleibieID=5 "
Set mrc1 = ExecuteSQL(txtsql)
End If
If Combo1.Text = "黑白" And Check1.Value = 0 Then
txtsql = "update FNo0006打印设定信息 set csflag='0 ',tpflag=False where dyleibieID=5 "
Set mrc1 = ExecuteSQL(txtsql)
End If
If Combo1.Text <> "黑白" And Check1.Value = 1 Then
txtsql = "update FNo0006打印设定信息 set csflag='1 ',tpflag=True where dyleibieID=5 "
Set mrc1 = ExecuteSQL(txtsql)
End If
If Combo1.Text <> "黑白" And Check1.Value = 0 Then
txtsql = "update FNo0006打印设定信息 set csflag='1 ',tpflag=False where dyleibieID=5 "
Set mrc1 = ExecuteSQL(txtsql)
End If
我用msgbox mrc1.RecordCount 显示的结果为1 ,而且也查看了数据表中的确只有一条符合条件的记录To: linkinwork(白菜)
表中有主键
如果是:
则在Dim mrc1 As ADODB.Recordset
后边,写上:
mrc1.Properties.Item("unique table") = "FNo0006打印设定信息"
试试看
"select dyleibieID,csflag ,tpflag from FNo0006 where dyleibieID=0 "对于查找的非主键rs,更新时就会出现如上现象,ok了吗