TO IVAN
是的,用VB写的,数据库是SQLSEVER7,我找不到错误。但就是报这个错,无法更新。:(

解决方案 »

  1.   

    建议你直接用sql语句试试
    sql="update table set col1='',....."
      

  2.   

    你的数据库是不是没有主键(主索引)啊?
    ADO就是这样的啦。
      

  3.   

    没有代码谁也没法帮你,但我想应该是你的权限或打开记录集的方式不对,详细的看MSDN中关于ADO的帮助信息。
      

  4.   

    谢谢大家!
    现在已经不报错了,可是怎么也存不进数据库了。我是个初手
    Public cnn As ADODB.Connection
    Public addflag As Boolean
    Public pcinfo As ADODB.Recordset
    Set pcinfo = New ADODB.Recordset
        pcinfo.Open "select infoid,jb_person.cyear as pcyear,jb_person.pid as ppid,pname,sex,nation," & _
                    "clan,knowledge,workinghours,duty,uname,pss,comptname,compstime," & _
                    "gradutime,pborn,jb_regent.cyear as ccyear,techsetid,sectionid,jb_regent.pid as cpid," & _
                    "rid,uption,doption,eoption,bin,tel,re from jb_person,jb_regent " & _
                    "where infoid = 8 and jb_person.pid = jb_regent.pid ", cnn, adOpenStatic, adLockOptimistic
    ……
    Public Function mnurdsave()
    'On Error Resume Next
    With pcinfo
         !infoid = 8
         !pcyear = Text(1).Text
         !ppid = Text(3).Text
         !pname = Text(2).Text
         !sex = rdsave(Combox(2), 1)
         !nation = rdsave(Combox(3), 2)
         !clan = rdsave(Combox(4), 2)
         !knowledge = rdsave(Combox(5), 2)
         !workinghours = DTPicker(2).Value
         !duty = rdsave(Combox(7), 2)
         !comptname = rdsave(Combox(8), 3)
         !compstime = DTPicker(4).Value
         !uname = Text(4).Text
         !pss = rdsave(Combox(6), 6)
         !gradutime = DTPicker(1).Value
         !pborn = DTPicker(0).Value
       If Optyes0(0).Value = True Then
           !uption = 1
         Else
           !uption = 0
        End If
       If Optyes1(1).Value = True Then
           !doption = 1
          Else
           !doption = 0
        End If
       If Optyes2(2).Value = True Then
           !eoption = 1
         Else
           !eoption = 0
        End If
       If !uption = 1 And !doption = 1 And !eoption = 1 Then
          !bin = 1
          Else
          !bin = 0
       End If
        
        !ccyear = Text(1).Text
        !techsetid = rdsave(Combox(0), 2)
        !sectionid = rdsave(Combox(1), 1)
        !cpid = Text(3).Text
        !rid = Text(0).Text
        !tel = Text(5).Text
        !re = Text(6).Text
        .Update
       End WithEnd Function
    Public Function rdread(ByVal mcmb As ComboBox, mstr As Variant) As Integer
    Dim i, j As Integer
    Dim serchi As Booleanserchi = False
    i = mcmb.ListCount - 1If mstr = "" Then
       rdread = -1
       Else
        Do While i > -1
            If mcmb.ItemData(i) = mstr Then
                 j = i
                 serchi = True
             Exit Do
            End If
              i = i - 1
           Loop
        End If
    If serchi = False Then
       rdread = -1
    Else: rdread = j
    End If
    End FunctionPublic Function rdsave(ByVal mcmb As ComboBox, i As Variant) As String
    Dim ystr As String
    If mcmb.ListIndex = -1 Then
          ystr = ""
            Else
              ystr = Right("0000000000" & mcmb.ItemData(mcmb.ListIndex), i)
      End If
    rdsave = ystr
    End Function
      

  5.   

    Open时参数
    adOpenStatic, adLockOptimistic
    改成 3, 3试试(对应的vb常量不记得了)
      

  6.   

    pcinfo.Open "select infoid,jb_person.cyear as pcyear,jb_person.pid as ppid,pname,sex,nation," & _
                    "clan,knowledge,workinghours,duty,uname,pss,comptname,compstime," & _
                    "gradutime,pborn,jb_regent.cyear as ccyear,techsetid,sectionid,jb_regent.pid as cpid," & _
                    "rid,uption,doption,eoption,bin,tel,re from jb_person,jb_regent " & _
                    "where infoid = 8 and jb_person.pid = jb_regent.pid ", cnn, adOpenStatic, adLockOptimistic
    中的adopenstatic,adlockoptimistic
    改为
    adopendynamic,adlockpessimistic
    具体说法看看MSDN
      

  7.   

    可能你的查询后的结果中有两行是相同 可以 在SQL语句中加上distinct