|
大写" Where oName Like '%JPG' " 不成立
小写" Where oName Like '%jpg " 成立
问: Sql like 如何实现UCASE的功能
*******************
- Function SqlRetuRs(SqlStr)
- Dim Cn As ADODB.Connection
- Set Cn = New ADODB.Connection
- Dim Rs As ADODB.Recordset
- Set Rs = New ADODB.Recordset
- '
- If InStr(UCase(Application.Path), "WPS") > 0 Then
- Cn.Open "Provider=Microsoft.JET.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=yes';Data Source=" & ThisWorkbook.FullName
- Else
- Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=yes';data source=" & ThisWorkbook.FullName
- End If
- Rs.Open SqlStr, Cn, adOpenKeyset, adLockOptimistic
- Set SqlRetuRs = Rs
- End Function
- Function SqlDistinctShtStr(SqlShtStr As String) As ADODB.Recordset
- Dim SqlStr
- 'Dim Rs As ADODB.Recordset
- SqlStr = "Select Distinct oDate,oName,oSize,oPath "
- SqlStr = SqlStr & SqlShtStr
- 'SqlStr = SqlStr & " Collate Name Like 'IMG%' "
- SqlStr = SqlStr & " Where oName Like '%JPG&' "
- Debug.Print SqlStr
-
- Set SqlDistinctShtStr = SqlRetuRs(SqlStr)
- End Function
复制代码
|
|