Private  Sub  Form_Load()  
Dim  rs  As  New  ADODB.Recordset  
Dim  sql  As  String  
Dim  strsql  As  String  
Dim  strsql1  As  String  
Dim  strsql2  As  String  
Dim  i  As  Integer  
On  Error  GoTo  handle  
       sql  =  "Provider=Microsoft.Jet.OLEDB.4.0;Data  Source="  &  _  
       ""  &  App.Path  &  "\db1.mdb;Persist  Security  Info=False"  
       cn.Open  sql  '连接数据库  
'检查数据  
strsql  =  "select  *  from  helptable"  
rs.Open  strsql,  cn,  adOpenKeyset,  adLockPessimistic  
i  =  rs.Fields("id")  +  1  
'删除表中数据  
strsql1  =  "delete  from  helptable"  
rs.Open  strsql1,  cn,  adOpenKeyset,  adLockPessimistic  
'添加新记录  
strsql2  =  "insert  into  helptable(id)values(i)"  
rs.Open  strsql2,  cn,  adOpenKeyset,  adLockPessimistic  
'判断  
If  rs.Fields("id")  =  30  Then  
     MsgBox  "程序到期请重新注册"  
     Unload  Me  
End  If  
Exit  Sub  
 
handle:  
       MsgBox  "数据库连接错误"  
End  Sub  
 
以上是我作的一个关于30次试用版本的信息,我知道数据库不能直接连接3次,可是怎么作呀?请指教,,,错误发生在RS。OPEN  STRSQL1  上面

解决方案 »

  1.   

    strsql  =  "select  *  from  helptable"  
    rs.Open  strsql,  cn,  adOpenKeyset,  adLockPessimistic  
    i  =  rs.Fields("id")  +  1  
    '删除表中数据  
    strsql1  =  "delete  from  helptable"  
    rs.Open  strsql1,  cn,  adOpenKeyset,  adLockPessimistic  
    '添加新记录  
    strsql2  =  "insert  into  helptable(id)values(i)"  
    rs.Open  strsql2,  cn,  adOpenKeyset,  adLockPessimistic  
    ----------------------------------------------------------
    上面这一段够呆的。
    我给你改一下
    strsql="update helptable set id=id+1"
    cn.execute strsql
    这样就行了!