值得一提的是,Access Database Engine 2010(又名“ACE”,“Jet”的继任者)支持该功能,可Replace()
在此处获得。要验证我是否在 Access 2003 数据库文件中创建了一个名为 [SomeTable] 的表:
ID s
-- ----------------------------
1 Everybody loves tofu!
2 Nobody really liked Raymond.
...我创建了一个名为 [stockReplaceQuery] 的已保存查询:
SELECT ID, Replace([s],"tofu","bacon") AS s1
FROM SomeTable;
当我使用以下 VBScript 测试 Jet ODBC 连接时
Option Explicit
Dim con, rst
Set con = CreateObject("ADODB.Connection")
con.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Users\Public\2003test.mdb;"
Set rst = CreateObject("ADODB.Recordset")
rst.Open "SELECT s1 FROM stockReplaceQuery WHERE ID = 1", con
WScript.Echo rst(0).Value
rst.Close
Set rst = Nothing
con.Close
Set con = Nothing
...我有
C:\__tmp>cscript /nologo repl.vbs
C:\__tmp\repl.vbs(6, 1) Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Undefined function 'Replace' in expression.
当我通过将con.Open
行更改为来测试 ACE ODBC 连接时
con.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\Public\2003test.mdb;"
...我有
C:\__tmp>cscript /nologo repl.vbs
Everybody loves bacon!
可能值得尝试安装 ACE 引擎/驱动程序,看看是否有帮助。