RLConn.OpenSchema(28,Array(Empty,Empty,TableName))
If Not RsPrimary.Eof Then GetPrimaryKey = RsPrimary("COLUMN_NAME")
Set RsPrimary = Nothing
If Err.Number <> 0 Then
Call ErrMsg("数据库不支持检测数据表 " & TableName & " 的主键。原因 :" & Err.Description)
Err.Clear()
End If
End Function
''---------------------------------------表结构操作-----------------------------------------------
''添加新字段
Public Function AddColumn(TableName,ColumnName,ColumnType)
On Error Resume Next
RLConn.Execute("Alter Table [" & TableName & "] Add [" & ColumnName & "] " & ColumnType & "")
If Err Then
ErrMsg ("新建 " & TableName & " 表中字段错误,请手动将数据库中 <B>" & ColumnName & "</B> 字段建立,属性为 <B>"&ColumnType& "</B>,原因" & Err.Description)
Err.Clear
AddColumn = False
Else
AddColumn = True
End If
End Function
''更改字段通用函数
Public Function ModColumn(TableName,ColumnName,ColumnType)
On Error Resume Next
RLConn.Execute("Alter Table [" & TableName & "] Alter Column [" & ColumnName & "] " & ColumnType & "")
If Err Then
Call ErrMsg ("更改 " & TableName & " 表中字段属性错误,请手动将数据库中 <B>" & ColumnName & "</B> 字段更改为 <B>" & ColumnType & "</B> 属性,原因" & Err.Description)
Err.Clear
ModColumn = False
Else
ModColumn = True
End If
End Function
''删除字段通用函数
Public Function DelColumn(TableName,ColumnName)
On Error Resume Next
If sDBType = "SQL" THen
RLConn.Execute("Alter Table [" & TableName & "] drop空格Column [" & ColumnName & "]")
Else
RLConn.Execute("Alter Table [" & TableName & "] drop空格[" & ColumnName & "]")
End if
If Err Then
Call ErrMsg ("删除 " & TableName & " 表中字段错误,请手动将数据库中 <B>" & ColumnName & "</B> 字段删除,原因" & Err.Description)
Err.Clear
DelColumn = False
Else
DelColumn = True
End If
End Function
''---------------------------------------表操作---------------------------------------------------
''打开表名对象
Private Sub ReNameTableConn()
On Error Resume Next
Set objADOXDatabase = Server.CreateObject("ADOX.Catalog")
objADOXDatabase.ActiveConnection = ConnStr
If Err Then
ErrMsg("建立更改表名对象出错,您所要升级的空间不支持此对象,您很可能需要手动更改表名,原因" & Err.Description)
Response.End
Err.Clear
End If
End Sub
''关闭表名对象
Private Sub CloseReNameTableConn()
Set objADOXDatabase = Nothing
Conn.Close
Set Conn=Nothing
End Sub
''更改数据库表名,入口参数:老表名、新表名
Public Function RenameTable(oldName, newName