ACCESS数据库不支持直接利用SQL语句实现更改表名,或者字段名,但可以ADOX对象来实现,范例代码如下:
复制代码 代码如下:<%
Call RenameTable("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\example.mdb", "test", "changed")
Sub RenameTable (conStr, oldName, newName)
'Has to be OLE DB connection
'Create object and connect to DB...
Dim objADOXDatabase
Set objADOXDatabase = Server.CreateObject("ADOX.Catalog")
objADOXDatabase.ActiveConnection = conStr
'Change the name...
objADOXDatabase.Tables(oldName).Name = newName
'Clean up...
Set objADOXDatabase = Nothing
End Sub
%>
复制代码 代码如下:<%
Call RenameTable("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\example.mdb", "test", "changed")
Sub RenameTable (conStr, oldName, newName)
'Has to be OLE DB connection
'Create object and connect to DB...
Dim objADOXDatabase
Set objADOXDatabase = Server.CreateObject("ADOX.Catalog")
objADOXDatabase.ActiveConnection = conStr
'Change the name...
objADOXDatabase.Tables(oldName).Name = newName
'Clean up...
Set objADOXDatabase = Nothing
End Sub
%>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“实现对Access数据库表重命名的一段代码”评论...