你少了 set cn=new adodb.connection
       cn.provider="Microsoft.Jet.OLEDB.4.0"
       set rs=new adodb.recordset
然后是rs.open......

解决方案 »

  1.   

    能看看你的connection string 吗?
      

  2.   

    不用RECORDSET,只用CONNECTIONcn.open "provider=sqloledb;server=yourcomputer;database=test;trusted_connection=yes"
    cn.execute "insert into test ('"& Trim(txtXh.Text) &"', '"& Trim(txtYear.Text))&"')"
      

  3.   

    注意以下几点:
    1、将你的
    rs.open "select xh,name from test",cn,adOpenStatic, adLockOptimistic
    改为:
    rs.open "select xh,name from test where id is null",cn,adOpenStatic, adLockOptimistic
    'id 是你的自增长字段
    2、注意数据类型
    如果你的rs.Fields(0)或rs.Fields(1)数据类型为整数的话
    要转换在对:
    rs.Fields(0)=Clng(Trim(txtXh.Text))