public conn as new adodb.Connection
public reco as new adodb.recordset
public connstring,commandstring as string
with conn
    .connectionstring=connstring
    .open
end with
with reco
    .ActiveConnection = Conn
    .LockType = adLockOptimistic
    .CursorType = adOpenDynamic
    .Source = Commandstring
    .Open
end with
with dbgrid1      //这是表格控件
     .ClearFields
     .ClearSelCols
     .Refresh
     .DataSource = Reco    //在运行的时候程序向我报出了“无此数据成员的错”
     .Refresh
End With

解决方案 »

  1.   

    .DataSource = Reco    //在运行的时候程序向我报出了“无此数据成员的错”把这一句该为
          .DataSource = Reco.Recordset.DataSource搞定!!!
      

  2.   

    dbGrid只能绑定Data控件,你要绑定ADO访问数据库的话用DataGrid控件吧
      

  3.   

    set conn = new ADODC.Recordset
    set reco = new ADODC.Recordset试一下在过程中加入如上两句
      

  4.   

    补充一下:
    connstring 该字符串有没有定义了SQL语句?如 connstring="select * from tablename"with dbgrid1      //这是表格控件
         .ClearFields
         .ClearSelCols
         .Refresh
         .DataSource = Reco   **换成set .DataSource = Reco
         .Refresh
    End Withwith reco
        .ActiveConnection = Conn
        .LockType = adLockOptimistic
        .CursorType = adOpenDynamic
        .Source = Commandstring **换成 set .Source = Commandstring
        .Open
    end with
      

  5.   

    abiao_521(小叫化) 正解!!!DBGrid和DataGrid不一样~~!!!DBGrid是基于DAO模型的(本人了解不多),可以简单得认为和Data控件绑定用。而DataGrid是DBGrid的ADO版本,也就是说用来绑定ADO控件或记录集对象时用。明白了吗?不懂再问哦!