作了一个简单的用datagrid显示数据的东西,在本机测试能够正常显示数据
但是在其他的机器上会出现“Cannot initialize data bindings”错误,绑定数据失败
这个问题困扰我很久了,一直没有解决。
希望高手指点。

解决方案 »

  1.   

    我用的 
    rs.open aaa.xml,,3,3
    set datagrid1.datasource=rs
      

  2.   

    //rs.open aaa.xml,,3,3
    估计是rs.open的问题
    代码放出来看看
      

  3.   

    Private Sub btnOpen_Click()
        CommonDialog1.Filter = "XML文件 (*.xml)|*.xml"
        CommonDialog1.ShowOpen
        If CommonDialog1.FileName = "" Then
            Exit Sub
        End If
        txtSource.Text = CommonDialog1.FileName
        If Right(txtSource.Text, 4) <> ".xml" Then
            MsgBox "请选择指定格式文件!"
            Exit Sub
        End If
        
    On Error GoTo Err:
        Dim rs As Recordset
        Set rs = New Recordset
        rs.Open txtSource.Text, , 1, 1
        Set DataGrid1.DataSource = rs
        DataGrid1.Refresh
        MsgBox "数据条数:" & rs.RecordCount
        Exit Sub
    Err:
        MsgBox "文件格式不正确或文件内容已损坏"
    End Sub