DBPath = "SourceDB=" & Server.MapPath( "DBC数据库文件名" )
' 连接数据库
conn.Open Driver & SourceType & DBPath
Set CreateDbcRecordset = Server.CreateObject("ADODB.Recordset")
' 打开数据表,参数二为Connection?对象
CreateDbcRecordset.Open "数据表名或Select语句", conn, 2, 2
End Function
5)将
Excel97或Excel2000生成的XLS文件(book)看成一个数据库,其中的每一个工作表(sheet)看成数据库表。
Function CreateExcelRecordset( XLS文件名,Sheet名 )
Dim conn.Driver,DBPath
' 建立Connection对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "XLS文件名" )
' 调用Open 方法打开数据库
conn.Open Driver & DBPath
Set CreateExcelRecordset = Server.CreateObject("ADODB.Recordset")
' 打开Sheet,参数二为Connection对象,因为Excel ODBC驱动程序无法直接用'sheet名来打开sheet,所以请注意以下的select语句
CreateExcelRecordset.Open "Select * From ["&sheet&”$]”, conn, 2, 2
End Function
6)SQL Server属于Server级的数据库,使用时要求比较严格,必须要求输入用户名及密码才能使用。
Function CreateSQLServerRecordset(计算机名称,用户ID, 用户密码,数据库名称 数据表或查看表或Select指令 )
Dim Params, conn
Set CreatSQLServerConnection = Nothing
Set conn = Server.CreateObject("ADODB.Connection")
Params = "Provider=SQLOLEDB.1"
Params = Params & ";Data Source=" & Computer
Params = Params & ";User ID=" & UserID
Params = Params & ";Password=" & Password
Params = Params & ".Initial Catalog="&数据库名称
Conn open Paras
Set CreateSQLServerRecordset = Server.CreateObject("ADODB.Recordset")