这条语句Set DataGrid1.DataSource = Adodc2 为什么出错?我有两个表,一个表一开始和Adodc1绑定
DataGrid1显示表1里的内容。我相在我单击单选按钮时,DataGrid1中的内容显示表2里的内容。我就设
Set DataGrid1.DataSource = Adodc2
DataGrid1.Refresh
可是出错呀。谢谢给予指导。

解决方案 »

  1.   

    先取消adodc1的绑定Set DataGrid1.DataSource =noting试试
      

  2.   

    还是不行呀。Set DataGrid1.DataSource =noting 成了这句有问题了。
      

  3.   

    提示什么出错了?adodc控件在哪绑定的(属性or代码)?
      

  4.   

    adodc1 是一开始在属性窗口中绑定的
      

  5.   

    我都在代码中绑定以后,option1的click事件中为
    Set DataGrid1.DataSource = Adodc1
    DataGrid1.Refresh
    option2的click事件中为
    Set DataGrid1.DataSource = Noting
    Set DataGrid1.DataSource = Adodc2
    运行时,Set DataGrid1.DataSource = Noting这一句出错。为什么
      

  6.   

    应是你的Adodc2的查询语句出错.
      

  7.   

    窗体上放:adodc1,adodc2,option1,option2,DataGrid1.代码如下:
    Private Sub Option1_Click()
    With Adodc1
       .ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\\fld.mdb;Persist Security Info=False"
       .CommandType = adCmdText
       .RecordSource = "select * from table1"
       .Refresh
    End With
    Set DataGrid1.DataSource = Adodc1
    End SubPrivate Sub Option2_Click()
    With Adodc2
       .ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\\fld.mdb;Persist Security Info=False"
       .CommandType = adCmdText
       .RecordSource = "select * from table2"
       .Refresh
    End With
    Set DataGrid1.DataSource = Adodc2
    End Sub
    试过了,没问题.
      

  8.   

    你没有把adodc2绑定好,在adodc2属性窗口中把adodc2绑定到同一个数据库的表2就行了。