The following part of the program can be said to be a universal database connector can connect almost all the MS database. <% '--------------------------------------------------- Function getmdbconnection (FileName) Dim Provider, DBPath
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;" DBPath = "Data source=" & Server.MapPath (FileName) Set getmdbconnection = getconnection (Provider & DBPath) End Function
'--------------------------------------------------- Function getsecuredmdbconnection (FileName, Password) Dim Provider, DBPath
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;" DBPath = "Data source=" & Server.MapPath (FileName) Set getsecuredmdbconnection = getconnection (Provider & DBPath &); Jet oledb:database password= "& Password) End Function
'--------------------------------------------------- Function getdbcconnection (FileName) Dim Driver, SourceType, DBPath
Driver = "Driver={microsoft Visual FoxPro Driver};" SourceType = "SOURCETYPE=DBC;" DBPath = "sourcedb=" & Server.MapPath (FileName) Set getdbcconnection = getconnection (Driver & sourcetype & DBPath) End Function
'--------------------------------------------------- Function getdbfconnection (Directory) Dim Driver, SourceType, DBPath
Driver = "Driver={microsoft Visual FoxPro Driver};" SourceType = "SOURCETYPE=DBF;" DBPath = "sourcedb=" & Server.MapPath (Directory) Set getdbfconnection = getconnection (Driver & sourcetype & DBPath) End Function
'--------------------------------------------------- Function getexcelconnection (FileName) Dim Driver, DBPath
Driver = "Driver={microsoft Excel Driver (*.xls)};" DBPath = "dbq=" & Server.MapPath (FileName) Set getexcelconnection = getconnection (Driver & "readonly=0;" & DBPath) End Function
'--------------------------------------------------- Function gettextconnection (Directory) Dim Driver, DBPath
Driver = "Driver={microsoft Text Driver (*.txt; *.csv)}; " DBPath = "dbq=" & Server.MapPath (Directory) Set gettextconnection = getconnection (Driver & DBPath) End Function
'--------------------------------------------------- Function getsqlserverconnection (Computer, UserID, Password, Db) Dim Params, Conn
Set getsqlserverconnection = Nothing Params = "Provider=SQLOLEDB.1" Params = Params & ";D ata source=" & Computer Params = Params & "; User id= "& UserID Params = Params & "; Password= "& Password Params = Params & "; Initial catalog=" & Db Set conn = Server.CreateObject ("ADODB. Connection ") Conn. Open Params Set getsqlserverconnection = conn End Function
'--------------------------------------------------- Function Getmdbrecordset (FileName, Source) Set Getmdbrecordset = Getmdbrs (FileName, Source, 2, "") End Function
'--------------------------------------------------- Function Getmdbstaticrecordset (FileName, Source) Set Getmdbstaticrecordset = Getmdbrs (FileName, Source, 3, "") End Function
'--------------------------------------------------- Function Getsecuredmdbrecordset (FileName, Source, Password) Set Getsecuredmdbrecordset = Getmdbrs (FileName, Source, 2, Password) End Function
'--------------------------------------------------- Function Getsecuredmdbstaticrecordset (FileName, Source, Password) Set Getsecuredmdbstaticrecordset = Getmdbrs (FileName, Source, 3, Password) End Function
'--------------------------------------------------- Function Getdbfrecordset (Directory, SQL) Set Getdbfrecordset = Getotherrs ("DBF", Directory, SQL, 2) End Function
'--------------------------------------------------- Function Getdbfstaticrecordset (Directory, SQL) Set Getdbfstaticrecordset = Getotherrs ("DBF", Directory, SQL, 3) End Function
'--------------------------------------------------- Function Getdbcrecordset (FileName, SQL) Set Getdbcrecordset = Getotherrs ("DBC", FileName, SQL, 2) End Function
'--------------------------------------------------- Function Getdbcstaticrecordset (FileName, SQL) Set Getdbcstaticrecordset = Getotherrs ("DBC", FileName, SQL, 3) End Function |