当前位置: 网学 > 编程文档 > ASP > 正文

在线管理数据库 类

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17
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 =

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号