标题:运行时错误'-2147217904(80040e10)':至少一个参数没有被指定值
只看楼主
shixyi37
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-2-6
 问题点数:0 回复次数:0 
运行时错误'-2147217904(80040e10)':至少一个参数没有被指定值
Sub test11()
  Dim cnn As New ADODB.Connection
  Dim rs As New ADODB.Recordset
  Dim sql As String
  Dim mybook As String
  mybook = ThisWorkbook.FullName
  With cnn
    If Application.Version = "11.0" Then
      .Provider = "microsoft.jet.oledb.4.0"
      .ConnectionString = "extended properties=""excel 8.0;HDR=YES;"";data source=" & mybook
    Else
      .Provider = "microsoft.ACE.oledb.12.0"
      .ConnectionString = "extended properties=""excel 12.0;HDR=YES;"";data source=" & mybook
    End If
    .Open
  End With
  sql = "select * from [期中$a2:e] where 编码 in (select 编码 from [期末$a2:e])"
  rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
  With Worksheets("期中期末共有")
    .Range("a4").CopyFromRecordset rs
  End With

  rs.Close
  sql = "select * from [期末$a2:e] where 编码 in (select 编码 from [期中$a2:e])"
  rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
  With Worksheets("期中期末共有")
    .Range("g4").CopyFromRecordset rs
  End With

  rs.Close
  sql = "select * from [期中$a2:e] where 编码 not in (select 编码 from [期末$a2:e])"
  rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
  With Worksheets("期中有期末没有")
    .Range("a4").CopyFromRecordset rs
  End With

  rs.Close
  sql = "select * from [期末$a2:e] where 编码 not in (select 编码 from [期中$a2:e] where not isnull(编码))"
  rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
  With Worksheets("期末有期中没有")
    .Range("a4").CopyFromRecordset rs
  End With
End Sub

运行上述宏时,出现以下错误:运行时错误'-2147217904(80040e10)':至少一个参数没有被指定值,点调试时显示错误在:rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
劳烦大师们施救
搜索更多相关主题的帖子: source excel 
2015-02-06 10:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-441818-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.011907 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved