纯
纯粹新手
Unregistered / Unconfirmed
GUEST, unregistred user!
高手帮忙看看,带颜色部分的,连接数据库怎么修改,原来是连接sql的,我现在需要连接access的,谢谢。
<Script language="VBScript" runat="server">
Class DataBase ' 操作数据库对象
Public DatabaseConnectionString 定义连接字符串
Public Conn 定义连接对象
Public Rs 定义记录集
实例化对象初始化
[red]Private Sub Class_Initialize
On Error Resume Next
DatabaseConnectionString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=data;User ID=sa;
Password=123 ;server=10.0.0.6"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DatabaseConnectionString
If Err.Number <> 0 then
Response.write "!!!!!!数据库链接出错!!!!!!请联系管理员!"
Response.End()
End If
End Sub [/red]查询记录总数
Public Function RecordCount(Sql)
On Error Resume Next
Dim CountNum,Rs1
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.Open Sql,Conn,1,1
If Not Rs1.Eof then
CountNum = Rs1.RecordCount
Rs1.close
If CountNum > 0 then
RecordCount = CountNum
else
RecordCount = 0
End If
else
<Script language="VBScript" runat="server">
Class DataBase ' 操作数据库对象
Public DatabaseConnectionString 定义连接字符串
Public Conn 定义连接对象
Public Rs 定义记录集
实例化对象初始化
[red]Private Sub Class_Initialize
On Error Resume Next
DatabaseConnectionString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=data;User ID=sa;
Password=123 ;server=10.0.0.6"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DatabaseConnectionString
If Err.Number <> 0 then
Response.write "!!!!!!数据库链接出错!!!!!!请联系管理员!"
Response.End()
End If
End Sub [/red]查询记录总数
Public Function RecordCount(Sql)
On Error Resume Next
Dim CountNum,Rs1
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.Open Sql,Conn,1,1
If Not Rs1.Eof then
CountNum = Rs1.RecordCount
Rs1.close
If CountNum > 0 then
RecordCount = CountNum
else
RecordCount = 0
End If
else