直播中
Function CreateSecuredMdbRecordset( 數(shù)據(jù)庫文件名, 數(shù)據(jù)表名或Select語句,password )
Dim conn,Provider,DBPath
‘ 建立Connection 對象
Set conn = Server.CreateObject("ADODB.Connection")
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data Source=" & Server.MapPath( "數(shù)據(jù)庫文件名" )
‘ 連接數(shù)據(jù)庫,注意下面一行帶有密碼參數(shù)
conn.Open Provider & DBPath&”Jet OLEDB:Database Password=”&assword
Set CreateSecuredMdbRecordset = Server.CreateObject("ADODB.Recordset")
‘ 打開數(shù)據(jù)表,參數(shù)二為Connection對象
CreateSecuredMdbRecordset.Open "數(shù)據(jù)表名", conn, 2, 2
End Function
3)DBF文件不是一個標準的數(shù)據(jù)庫文件,只相當于標準數(shù)據(jù)庫文件中的一個數(shù)據(jù)表,所以為了使用DBF文件,采用把所
有的DBF文件放在一個目錄下,這樣把目錄名看成標準數(shù)據(jù)中的數(shù)據(jù)庫表,每一個DBF文件相當于標準數(shù)據(jù)庫的數(shù)據(jù)表。下
面函數(shù)中Directory是DBF所在的目錄名,
Function CreateDbfRecordset( 目錄名, DBF文件名或Select語句 )
Dim conn,Driver,SourceType,DBPath
‘ 建立Connection 對象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( "目錄名" )
‘ 調(diào)用Open 方法打開數(shù)據(jù)庫
conn.Open Driver & SourceType & DBPath
Set CreateDbfRecordset = Server.CreateObject("ADODB.Recordset")
‘ 打開DBF文件,參數(shù)二為Connection對象
CreateDbfRecordset.Open DBF文件名或Select語句, conn, 2, 2
End Function
4)由Foxpro生成的DBC數(shù)據(jù)庫與MDB數(shù)據(jù)庫相似,都是一個數(shù)據(jù)庫包含幾個數(shù)據(jù)表的形式,所以對DBC數(shù)據(jù)庫的存取方
法與MDB數(shù)據(jù)庫相似。
Function CreateDbcRecordset( DBC數(shù)據(jù)庫文件名, 數(shù)據(jù)表名或Select語句 )
Dim conn,Driver,SourceType,DBPath
‘ 建立Connection 對象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBC;"