所得记录为何不能绑在Datagrid上,提示错误:行集合不能作为标签。代码如下。
    cnn.Open str
    Set cm.ActiveConnection = cnn
    cm.CommandType = adCmdStoredProc
    cm.CommandText = "P_order"
    prm.Type = adInteger
    prm.Direction = adParamInput
    prm.Value = Val(Text1.Text)
    cm.Parameters.Append prm
    rst.CursorLocation = adUseClient
    Set rst = cm.Execute()
    Set DataGrid1.DataSource = rst  ——>>提示有错!

解决方案 »

  1.   

    这是因为你所创建的这个记录的条数为-1建议你不要用CM.execute而是RST.OPEN
      

  2.   

    同意zymfy
      这是由于你的记录集条数为-1
      

  3.   

    奇怪!我在SQL2000中执行储存过程很正常,现在我要用ADO运行SQL2000中的储存过程,rst.open不能执行只能用cm.execute().
    为何有"行集合不能作为标签",实在不解.
      

  4.   

    记录集条数为-1?It's impossible!
      

  5.   

    你要以静态方式打开的记录集才能返回正确的记录数
    而且动态方式不支持book不能设置成datagrid的数据源
    另外sqlserver和access返回的记录集方式还是有差异的
      

  6.   

    RST.Open "select * from table ", CN, adOpenStatic, adLockReadOnlySet DataGrid1.DataSource = rst要用adOpenStatic打开记录集
      

  7.   

    各位注意我是要执行储存过程,难到rescordset支持储存过程,所以我得用command!
      

  8.   

    试试cnn.CursorLocation = adUseClient
      

  9.   

    用cnn.CursorLocation = adUseClient不行!
    RS.OPEN后面可以不带参数?