我在:
工程->部件:MIcrosoft DataGrid Control 6.0(OLEDB)
工程->引用:Microsoft ActiveX Data Object 2.1 Library
我在按钮事件里,对DataGrid控件进行ClearFields后,用Rebind命令时,
总是说“不能初始化数据绑定”,这是什么问题啊!

解决方案 »

  1.   

    Function view()
    sql = "select*from table"
    Set rs = ExecuteSQL(sql)    **********一个连接数据库的函数
    Set DataGrid1.DataSource = rs
    With DataGrid1
    .Columns(0).Width = 1000
    .Columns(1).Width = 1100
    .Columns(2).Width = 1000
    .Columns(0).Caption = "单位编号"
    .Columns(1).Caption = "单位名称"
    .Columns(2).Caption = "单位简称"
    End With
    End Function
    这样可以初始化不知道楼主是不是这个意思
      

  2.   

    好像要刷新一下数据库的连接吧
    XXXconnect.close
    再XXXconnect.open
      

  3.   

    你使用的是ADO对象,不是ADO控件不能进行绑定。只有这样:set datagrid1.datasource=nothing'清空
    datagrid1.refresh
    set datagrid1.datasource=rs'重新载入记录集
    datagrid1.refresh
      

  4.   

    你们三人的方法,我的用了,但还是不能显示数据啊!
    还有:to chenyu5188
    你能告诉我为什么ADO对象不能绑定啊,我用了你的方法不能显示数据啊!
      

  5.   

    set datagrid1.datasource=nothing'清空
    datagrid1.refresh
    rs.CursorLocation=adUseclient'使用客户端游标
    set datagrid1.datasource=rs'重新载入记录集
    datagrid1.refresh
      

  6.   

    不可能的啊
    我这已经是调试成功的啊对了我用的工程->部件:Microsoft ADO Data Control6.0(SP4)
      

  7.   

    编程序的高人指点,摸索一很重要呀
    你不能再DataGrid直接设置column(i)的标题,这样肯定不能显示,我也是这样,不过我摸索了然后高定,DataGrid.column(i) = "用户号",高定了,要给分呀!!!