Sql Array运行时错误13,输入Mismatch

时间:2017-09-21 12:56:12

标签: excel vba select type-mismatch

我需要一些帮助。我有以下查询返回运行时错误13,每次运行它时,选择数组上键入Mismatch,列数选择大于16.我根据不同的逻辑删除了列,但是唯一常见的是,如果列少于16列,它就可以工作。我知道这听起来很奇怪。 我尝试以不同的方式打破数组,结果相同。 我究竟做错了什么?我在代码下面使用。 感谢您提供的任何帮助。

   With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
    "OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=CFO_NPR;Data Source=ORDCWPDBSNFD01" _
    , _
    ";Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=EDFLDDIL001;Use Encryption for Data=False;Tag w" _
    , "ith column collation when possible=False"), Destination:=Range("$A$1")). _
    QueryTable
    .CommandType = xlCmdSql
    .CommandText = Array( _
    "Select facility_name, int_no, lwbbs, admit, level, peds, psych, arr, trg, ord, dis, dep, ""arr>phy"", ""arr>dis"", ""arr>dep"",""phy>ord"", ""phy>dis"", ""dis>dep"", hold,  arrh, dish, deph, rept_date, erDisp, ready from ""CFO_NPR"".""dbo"".""efdv_edWait"" WHERE rept_date >= dateadd(day,-32,getdate()) and rept_date <= dateadd(day,-1,getdate())")
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .PreserveColumnInfo = True
    .SourceConnectionFile = _
    "S:\ED-EMS\Maurizio Reports\EFD In-Season Performance Report\Daily AH\Daily Stats.odc"
    .ListObject.DisplayName = "Table_Division_Daily_Stats"
    .Refresh BackgroundQuery:=False
End With
ActiveSheet.Columns("H:L").NumberFormat = "MM/DD/YY HH:MM"

0 个答案:

没有答案