)
On Error Resume Next
Call ReNameTableConn
objADOXDatabase.Tables(oldName).Name = newName
If Err Then
Call ErrMsg ("更改表名错误,请手动将数据库中 <B>" & oldName & "</B> 表名更改为 < B>" & newName & "</B>,原因" & Err.Description)
Err.Clear
RenameTable = False
Else
RenameTable = True
End If
Call CloseReNameTableConn
End Function
''删除表通用函数
Public Function DelTable(TableName)
On Error Resume Next
RLConn.Execute("drop空格Table [" & TableName & "]")
If Err Then
ErrMsg ("删除 " & TableName & " 表错误,请手动将数据库中 <B>" & TableName&"</B> 表删除,原因" & Err.Description)
Err.Clear
DelTable = False
Else
DelTable = True
End If
End Function
''建立新表
Public Function CreateTable(ByVal TableName,ByVal FieldList)
Dim StrSql
If sDBType = "SQL" THen
StrSql = "CREATE TABLE [" & TableName & "]( " & FieldList & ")"
Else
StrSql = "CREATE TABLE [" & TableName & "]"
End if
RLConn.Execute(StrSql)
If Err.Number <> 0 Then
Call ErrMsg("新建 " & TableName & " 表错误,原因" & Err.Description & "")
Err.Clear()
CreateTable = False
Else
CreateTable = True
End If
End Function
''---------------------------------------数据库操作-----------------------------------------------
''建立数据库文件
Public function CreateDBfile(byVal dbFileName,byVal SavePath)
On error resume Next
SavePath = Replace(SavePath,"/","\")
If Right(SavePath,1)<>"\" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "\"
If Left(dbFileName,1)="\" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName)))
If DbExists(AppPath() & SavePath & dbFileName) Then
ErrMsg("对不起,该数据库已经存在!" & AppPath() & SavePath & dbFileName)
CreateDBfile = False
Else
Response.Write AppPath() & SavePath & dbFileName
Dim Ca
Set Ca = Server.CreateObject("ADOX.Catalog")
If Err.number<>0 Then
ErrMsg("无法建立,请检查错误信息<br>" & Err.number & "<br>" & Err.Description)
Err.Clear
CreateDBfile = False
Exit function
End If
call Ca.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AppPath() & SavePath & dbFileName)
Set Ca = Nothing
CreateDBfile = True
End If
End function
''查找数据库文件是否存在
Private function DbExists(byVal dbPath)
On Error resume Next
Dim c
Set c = Server.CreateObject("ADODB.Connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath