Dim cnn As New ADODB.Connection
    Dim rs As New ADODB.Recordset    cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=kaoping;Data Source=192.168.1.3"
        
        Dim tot(1 To 3) As Integer
        Set rs = cnn.Execute("select * from diaocha where num=1")
        tot(1) = rs.Fields("A") + SNum(1)
        tot(2) = rs.Fields("B") + SNum(2)
        tot(3) = rs.Fields("C") + SNum(3)
        
        Set rs = cnn.Execute("update diaocha set A=" + Val(tot(1)) + ",B=" + Val(tot(2)) + ",C=" + Val(tot(3)) + " where Num=1")
sql表里A,B,C字段的类型都是int型的为什么执行最后一句的时候总是报实时错误(13),类型不匹配呢?哪位大侠帮帮我

解决方案 »

  1.   

    strsql=" update diaocha set a=isnull(a,0)+"& tot(1) &",b=isnull(b,0)+"& tot(2) &",c=isnull(c,0)+"& tot(3) &" where num=1 "
    cnn.execute strsql
      

  2.   

    对一行还是多行只要在where 后加条件就可以:
    where num=1 就是对num为1的更新
    where num between 1 10 就是对num为1至10的记录更新
      

  3.   


    这是表结构,用between不行啊,因为只有num是固定不变的,abc是根据投票累加的啊
      

  4.   

    num     a      b        c
    1       0      0        0
    2       0      0        0
    3       0      0        0
    4       0      0        0
    5       0      0        0这是表结构
      

  5.   

    strsql=" update diaocha set a=isnull(a,0)+"& tot(1) &",b=isnull(b,0)+"& tot(2) &",c=isnull(c,0)+"& tot(3) &" where num=1 " 
    cnn.execute strsql