dbret.CursorLocation = adUseClient
 
cmd.CommandText = "select * from datainfo"Set dbret = cmd.Execute
Set DataGrid1.DataSource = dbret以上代碼,在執行到第一句就出現錯誤“物件開啟時,不允許操作”,我的系統是繁體的,可能簡體報的不是這個,各位大俠看看什么問題。

解决方案 »

  1.   

    dbret.CursorLocation = adUseClient 
    dbret.open "select * from datainfo",conn,adopenkeyset,adlockreadonly
    Set DataGrid1.DataSource = dbret 
      

  2.   

    還是一樣的錯誤,謝謝你,我想是因為在別的SUB里OPEN了沒有CLOSE,但是我要怎麼判斷DB是OPEN的還是CLOSE的。這樣我在用之前就可以先CLOSE掉。
      

  3.   

    dbret.CursorLocation = adUseClient 
    if dbret.state<>adstateclosed then dbret.close
    dbret.open "select * from datainfo",conn,adopenkeyset,adlockreadonly 
    Set DataGrid1.DataSource = dbret