Recommended: parse syntax parameters of DateDiff function Description returns the time interval between two dates. Syntax DateDiff(interval, date1, date2 [,firstdayofweek][, firstweekofyear]]) The syntax of the DateDiff function has the following parameters: Parameter description interval Required. String expression represents the time interval used to calculate date1 and date2. Related values
1. Create an MdbRecordset object. An MDB database is a complete database that may contain several data tables. In this function, the function of Connection is to connect to the database, and the function of Recordset is to open the data table.
| Function CreateMdbRecordset (database file name, data table name or Select statement) Dim conn, Provider, DBPath 'Create Connection object Set conn = Server.CreateObject (ADODB.Connection) Provider=Provider=Microsoft.Jet.OLEDB.4.0; DBPath = Data Source= & Server.MapPath (database file name) 'Open the database conn.Open Provider & DBPath Set CreateMdbRecordset = Server.CreateObject(ADODB.Recordset) 'Open the data table CreateMdbRecordset.Open Data table name, conn, 2, 2 End Function |
2. Create a Recordset object for the MDB database with password. Its establishment method is similar to the Recordset object that establishes a MDB database without passwords, except that there is an additional password parameter, that is, when connecting to the database, password information must be given.
| FunctionCreateSecuredMdbRecordset (database file name, data table name or select statement, password) Dimconn, Provider, DBPath 'Create Connection object Setconn=Server.CreateObject (ADODB.Connection) Provider=Provider=Microsof.Jet.OLEDB.4.0; DBPath=DataSource=&Server.MapPath(database file name) 'Connect the database, be careful to have password parameters conn.OpenProvider & DBPath & JetOLEDB:DatabasePassword=&assword SetCreateSecuredMdbRecordset=Server. CreateObject(ADODB.Recordset) 'Open the data table CreateSecuredMdbRecordset.Open data table name,conn,2,2 EndFunction |
3. DBF files are not a standard database file, but are only equivalent to a data table in a standard database file. Therefore, in order to use DBF files, you can put all DBF files in one directory, so that the directory name is regarded as a standard database, and each DBF file is equivalent to a data table in a standard database. The Directory in the following function is the directory name where DBF is located.
| FunctionCreateDbfRecordset (directory name, DBF file name or Select statement) Dimconn, Driver, SourceType, DBPath 'Create Connection object Setconn=Server.CreateObject (ADODB.Connection) Driver=Driver={MicrosoftVisualFoxProDriver};SourceType=SourceType=DBF; DBPath=SourceDB=&Server.MapPath(directory name) 'Call Open method to open the database conn.OpenDriver & SourceType & DBPath SetCreateDbfRecordset=Server.CreateObject(ADODB.Recordset) 'Open DBF file CreateDbfRecordset.OpenDBF file name or Select statement,conn,2,2 EndFunction |
4. The DBC database generated by FoxPro is similar to the MDB database. Both are in the form of a database containing several data tables, so the access method of the DBC database is similar to that of the MDB database.
| FunctionCreateDbcRecordset (DBC database file name, data table name or Select statement) Dimconn, Driver, SourceType, DBPath 'Create Connection object Setconn=Server.CreateObject (ADODB.Connection) Driver=Driver={MicrosoftVisualFoxProDriver}; SourceType=SourceType=DBC; DBPath=SourceDB=&Server.MapPath(DBC database file name) 'Connect the database conn.OpenDriver & SourceType & DBPath SetCreateDbcRecordset=Server.CreateObject(ADODB.Recordset) 'Open the data table CreateDbcRecordset.Open data table name or Select statement,conn,2,2 EndFunction |
5. Treat the XLS file (book) generated by Excel as a database, and each worksheet (sheet) is regarded as a database table.
| Function CreateExcelRecordset (XLS file name, Sheet name) Dim conn.Driver,DBPath 'Create Connection object Set conn = Server.CreateObject (ADODB.Connection) Driver=Driver={Microsoft Excel Driver (*.xls)}; DBPath = DBQ= & Server.MapPath(XLS file name) 'Call Open method to open the database conn.Open Driver & DBPath Set CreateExcelRecordset = Server.CreateObject(ADODB.Recordset) 'Open Sheet CreateExcelRecordset.Open Select * From [&sheet&$], conn, 2, 2 End Function |
6.SQL Server
| FunctionCreateSQLServerRecordset (computer name, user ID, user password, database name data table or view table or Select directive) DimParams,conn SetCreatSQLServerConnection=Nothing Setconn=Server.CreateObject (ADODB.Connection) Params=Provider=SQLOLEDB.1 Params=Params&;DataSource=&Computer Params=Params&;UserID=&UserID Params=Params&;Password=&Password Params=Params&.InitialCatalog=&Database Name ConnopenParas SetCreateSQLServerRecordset=Server. CreateObject(ADODB.Recordset) CreateSQLServerRecordset.Opensource,conn,2,2 EndFunction |
Share: A brief analysis of a good page turn effect code Note: The file name should be index.asp. The display effect is as follows: 100 items in total. The current page 8/11 top page is the previous page [6] [7] [8] [9] [10] Next page end page next page!--#includefile=conn.asp-- %PageShowSize=5'How many pages are displayed per page MyPageSize=10'How many articles are displayed per page IfNotIsNumeric(R