本帖最后由 czjt1234 于 2016-4-23 20:06 编辑
- 'win7x64,强制在32位环境运行脚本
- Set oWS = CreateObject("WScript.Shell")
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- s = oWS.ExpandEnvironmentStrings("%windir%\SysWOW64\WScript.exe")
- If oFSO.FileExists(s) = True And LCase(WScript.FullName) <> LCase(s) Then
- oWS.Run s & " """ & WScript.ScriptFullName & """"
- WScript.Quit()
- End If
-
- '创建新数据库文件
- If oFSO.FileExists("c:\new.mdb") Then oFSO.DeleteFile "c:\new.mdb"
- Set oCatalog = CreateObject("Adox.Catalog")
- oCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb;Jet OLEDB:Database Password=test;"
-
- '连接数据库
- Set oConnection = CreateObject("Adodb.Connection")
- oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb;Jet OLEDB:Database Password=test;"
-
- '创建表
- oConnection.Execute "Create Table 成绩(学号 SmallInt, 成绩 Real)"
- WScript.Sleep 500
-
- 'oConnection.Execute "Drop Table 成绩" '这个不报错
-
- '修改表名
- Set oCatalog = CreateObject("Adox.Catalog")
- Set oCatalog.ActiveConnection = oConnection
- oCatalog.Tables.Item("成绩").Name = "8(9)班成绩"
-
- '删除表
- oConnection.Execute "Drop Table 8(9)班成绩"
复制代码 最后一行报错,SQL里面的()是特殊符号
试了
"Drop Table 8\(9\)班成绩"
"Drop Table 8((9))班成绩"
"Drop Table 8[(]9[)]班成绩"
"Drop Table 8" & Chr(40) & "9" & Chr(41) & "班成绩"
都不行
access数据库SQL语言里面的特殊符号怎么处理? |