End If
End Sub
''执行SQL语句
Public Sub Execute(StrSql)
Set RsCount=Server.CreateObject("ADODB.RecordSet")
On Error Resume Next
RsCount = RLConn.Execute(StrSql)
If Left(StrSql,12) = "Select Count" Then Count = RsCount(0)
If Err.Number <> 0 Then
Call ErrMsg("错误提示:" & Err.Description)
Err.Clear()
End If
RsCount.Close
Set RsCount = Nothing
End Sub
''---------------------------------------索引(Index),视图(View),主键操作-----------------------------------------------
''添加字段索引
Public Function AddIndex(ByVal TableName, ByVal IndexName, ByVal ValueText)
On Error Resume Next
RLConn.Execute("CREATE INDEX " & IndexName & " ON [" & TableName & "]([" & ValueText & "])")
If Err.Number <> 0 Then
Call ErrMsg ("在 " & TableName & " 表新建" & IndexName & "索引错误,原因" & Err.Description & "请手工修改该索引。")
Err.Clear()
AddIndex = False
Else
AddIndex = True
End If
End Function
''删除表索引
Public Function DelIndex(ByVal TableName, ByVal IndexName)
On Error Resume Next
RLConn.Execute("drop空格INDEX [" & TableName & "]." & IndexName)
If Err.Number <> 0 Then
Call ErrMsg ("在 " & TableName & " 表删除" & IndexName & "索引错误,原因" & Err.Description & "请手工删除该索引。")
Err.Clear()
DelIndex = False
Else
DelIndex = True
End If
End Function
''更改表TableName的定义把字段ColumnName设为主键
Public Function AddPRIMARYKEY(ByVal TableName, ByVal ColumnName)
On Error Resume Next
TableName = Replace(Replace(TableName,"[",""),"]","")
RLConn.Execute("ALTER TABLE "& TableName & " ADD CONSTRAINT PK_"&TableName&" PRIMARY KEY (" & ColumnName & ")")
If Err.Number <> 0 Then
Call ErrMsg ("在 " & TableName & " 将字段" & ColumnName & " 添加为主键时出错,原因 " & Err.Description & "请手工修改该字段属性。")
Err.Clear()
AddPRIMARYKEY = False
Else
AddPRIMARYKEY = True
End If
End Function
''更改表TableName的定义把字段ColumnName主键的定义删除
Public Function DelPRIMARYKEY(ByVal TableName, ByVal ColumnName)
On Error Resume Next
RLConn.Execute("ALTER TABLE "& TableName & " drop空格PRIMARY KEY (" & ColumnName & ")")
If Err.Number <> 0 Then
Call ErrMsg ("在 " & TableName & " 将字段" & ColumnName & " 主键的定义删除时出错,原因" & Err.Description & "请手工修改该字段属性。")
Err.Clear()
DelPRIMARYKEY = False
Else
DelPRIMARYKEY = True
End If
End Function
''检查主键是否存在,返回该表的主键名
Function GetPrimaryKey(TableName)
on error Resume Next
Dim RsPrimary
GetPrimaryKey = ""
Set RsPrimary =