Function FsoChange (Filename, Target, String)
Dim objfso, ObjcountFile, FileTempdata
Set objfso = server.createObject ("scripting.filesystemObject")
Set objcountfile = objfso.opentextfile (server.mappath (filename), 1, true)
FileTempdata = ObjcountFile.Readall
ObjcountFile.Close
FileTempdata = Replace (FileTempdata, Target, String)
Set objcountfile = objfso.createtextfile (server.mappath (filename), true)
Objcountfile.write filetempdata
ObjcountFile.Close
Set objcountfile = Nothing
Set objfso = Nothing
END FUNCTION
'' 'Uses FSO to read the function of the file content
Function fsofileread (filename)
Dim objfso, ObjcountFile, FileTempdata
Set objfso = server.createObject ("scripting.filesystemObject")
Set objcountfile = objfso.opentextfile (server.mappath (filename), 1, true)
FsofileRead = ObjcountFile.Readall
ObjcountFile.Close
Set objcountfile = Nothing
Set objfso = Nothing
END FUNCTION
'' 'Uses FSO to read the function of a line of files
Function FsolineDit (filename, linenum)
IF Linenum <1 THEN EXIT FUNCTION
DIM FSO, F, TEMPARRAY, TEMPCNT
SET FSO = Server.createObject ("scripting.filesystemObject")
IF not fso.fileexists (server.mappath (filename)) THEN EXIT FUNCTION
Set f = fso.opentextfile (server.mappath (filename), 1)
IF not f.atendofstream Then
Tempcnt = f.readall
f.close
Set f = Nothing
Temparray = Split (Tempcnt, Chr (13) & chr (10))
If Linenum> Ubound (Temparray) 1 THEN
EXIT FUNCTION
Else
FSOLinedit = Temparray (LINENUM-1)
END IF
END IF
END FUNCTION
'' 'Uses FSO to write a function of a certain line
Function FsolineWrite (FileName, Linenum, LineContent)
IF Linenum <1 THEN EXIT FUNCTION
DIM FSO, F, TEMPARRAY, TEMPCNT
Set fso = server.createObject ("scripting.filesystemObject") if not fso.fileexists (server.mappath (filename)) THEN EXIT FUNCTION
Set f = fso.opentextfile (server.mappath (filename), 1)
IF not f.atendofstream Then
Tempcnt = f.readall
f.close
Temparray = Split (Tempcnt, Chr (13) & chr (10))
If Linenum> Ubound (Temparray) 1 THEN
EXIT FUNCTION
Else
Temparray (LINENUM-1) = linecontent
END IF
Tempcnt = JOIN (Temparray, Chr (13) & chr (10))
Set f = fso.createtextfile (server.mappath (filename), true)
F.Write Tempcnt
END IF
f.close
Set f = Nothing
END FUNCTION
'' 'Uses FSO to add files to new line functions
Function FsoAppline (filename, linecontent)
DIM FSO, F
SET FSO = Server.createObject ("scripting.filesystemObject")
IF not fso.fileexists (server.mappath (filename)) THEN EXIT FUNCTION
Set f = fso.opentextfile (server.mappath (filename), 8, 1)
F.Write Chr (13) & chr (10) & linecontent
f.close
Set f = Nothing
END FUNCTION
'' '' Read the last line of the file
Function fsolastline (filename)
DIM FSO, F, TEMPARRAY, TEMPCNT
SET FSO = Server.createObject ("scripting.filesystemObject")
IF not fso.fileexists (server.mappath (filename)) THEN EXIT FUNCTION
Set f = fso.opentextfile (server.mappath (filename), 1)
IF not f.atendofstream Then
Tempcnt = f.readall
f.close
Set f = Nothing
Temparray = Split (Tempcnt, Chr (13) & chr (10))
Fsolastline = Temparray (Ubound (TempaRay))
END IF
END FUNCTION
'Also, create a folder:
SUB CREATEFOLDER (FolderName)
SET AFSO = Server.createObject ("scripting.filesystemObject")
IF AFSO.FOLDEREXISTS (Server.Mappath (FolderName)) = true kil
Else
AFSO.CREATEFOLDER (server.mappath (foldername))
END IF
Set Afso = Nothing Sub
'Usage, CreateFolder (FolderName)
Traversal Directory and the function of the files under the directory
Function Bianli (PATH)
SET FSO = Server.createObject ("scripting.filesystemObject")
ON Error ResMe next
Set objfolder = fso.getfolder (PATH)
Set objsubfolders = Objfolder.subfolders
For Each Objsubfolder In Objsubfolders
NowPath = PATH "/" Objsubfolder.name
Response.write nowpath
Set Objfiles = Objsubfolder.files
For Each Objfile in Objfiles
Response.write "
---"
Response.write objfile.name
NEXT
Response.write "
"
Bianli (nowPath) 'recursive
NEXT
Set objfolder = Nothing
Set objsubfolders = Nothing
SET FSO = Nothing
END FUNCTION
%>
<%
'Bianli ("D:")' Traversed D: Disc
%>
<%
'Replace the function of specifying the string of the file
Function FsolineEd (Filename, Target, String)
Dim objfso, ObjcountFile, FileTempdata
Set objfso = server.createObject ("scripting.filesystemObject")
Set objcountfile = objfso.opentextfile (server.mappath (filename), 1, true)
FileTempdata = ObjcountFile.Readall
ObjcountFile.Close
FileTempdata = Replace (FileTempdata, Target, String)
Set objcountfile = objfso.createtextfile (server.mappath (filename), true)
Objcountfile.write filetempdata
ObjcountFile.Close
Set objcountfile = Nothing
Set objfso = Nothing
END FUNCTION
Response.Write FsolineEdit ("Test.txt", "World", "Tomorrow is a good day")
%>
Keep the value in the refresh text box
.savehistory {behavior: URL (# default # savehistory);
Style>
body>
Html>
5 ways to connect the database in the ASP
5 ways to connect the database in the ASP
(01-3-30 199)
From: chinaasp.com by cauli
The first type - this method is used in access in Access
StrConn = "driver = microsoft access driver (* .mdb); dbq =" & server.mappath ("aspfree.mdb")
Set conn = server.createObject ("adoDb.connection")
Conn.open straconn
Second, this method is used in SQL Server
Strconn = "driver = {SQL
Server}; description = sqldemo; server = 127.0.0.1; uid = loginid; pwd = password; database = dataBase_name
Set conn = server.createObject ("adoDb.connection")
Conn.open straconn
Third
Strconn = "driver = {MicrosoftAccessDriver (*. mdb)};" & _
"DBQ = f: /inetpub/wwroot/somedir/db1.mdb; defaultdir = f: / inetpub / wwwroot / Somedir; UID = Loginid;" & _
"PWD = password; driverid = 25; FIL = msaccess;" set conn = server.createObject ("adodb.connection")
Conn.open straconn
Fourth type of system data source
The Following Uses A Data Source Name:
Set conn = server.createObject ("adoDb.connection")
Conn.open "Example"
The fifth use ODBC data source, provided that you must set up data sources in the ODBC of the control panel
SET RS = Server.createObject ("AdoDb.Recordset")
Rs.Open "TBLNAME", "DSNName", 3, 3
Chinese character judgment (JS judgment)
For (i = 0; i Char = realname.charcodeat (i); IF (! (char> 255)) { Alert ("The real name should be Chinese characters!"); Userform.realname.focus (); Return False; } } '' Identity Authenticity '' ID provincial certificate number '' Birthday birthday, YYYY-MM-DD format '' SEX gender, the value is "male: 1", "female: 0" ID = "460102800925121" BIRTHDAY = "1980-09-25" SEX = 1 If IDCARD_CHECK (ID, birthday, sex) ThenResponse.write "No" Else Response.write "**" END IF Function IDCARD_CHECK (ID, Birthday, SEX) IF LEN (ID) <> 15 and Len (ID) <> 18 THEN IDCARD_CHECK = FALSE EXIT FUNCTION Else For i = 1 to Len (ID) Temp = MID (ID, i, 1) IF Temp <"0" or Temp> "9" THEN IDCARD_CHECK = FALSE EXIT FUNCTION END IF NEXT BDL = Left (Birthday, 4) & Mid (Birthday, 6, 2) & Mid (Birthday, 9, 2) BDS = MID (Birthday, 3, 2) & Mid (Birthday, 6, 2) & Mid (Birthday, 9, 2) IF LEN (ID) = 15 THEN IF MID (ID, 7, 6) <> BDS THEN IDCARD_CHECK = FALSE EXIT FUNCTION END IF IF INT (MID (ID, 15, 1)) MOD 2 = 1 and sex = 1 THEN IDCARD_CHECK = TRUE EXIT FUNCTION Elseif Int (MID (ID, 15, 1)) MOD 2 = 0 and SEX = 0 THEN IDCARD_CHECK = TRUE EXIT FUNCTION Else IDCARD_CHECK = FALSE EXIT FUNCTION END IF Else IF MID (ID, 7, 8) <> BDL THEN IDCARD_CHECK = FALSE EXIT FUNCTION END IF IF INT (MID (ID, 17, 1)) MOD 2 = 1 and sex = 1 THEN IDCARD_CHECK = FALSE EXIT FUNCTION Elseif Int (MID (ID, 17, 1)) MOD 2 = 0 and SEX = 0 THEN IDCARD_CHECK = FALSE EXIT FUNCTION Else IDCARD_CHECK = FALSE EXIT FUNCTION END IF END IF END IF IDCARD_CHECK = TRUE END FUNCTION 11 = "Beijing" 12 = "Tianjin" 13 = "Hebei" 14 = "Shanxi" 15 = "Inner Mongolia" 21 = "Liaoning" 22 = "Jilin" 23 = "Heilongjiang" 31 = "Shanghai" 32 = "Jiangsu" 33 = "Zhejiang" 34 = "Anhui" 35 = "Fujian" 36 = "Jiangxi" 37 = "Shandong" 41 = "Henan" 42 = "Hubei" 43 = "Hunan" 44 = "Guangdong" 45 = "Guangxi" 46 = "Hainan" 50 = "Chongqing" 51 = "Sichuan" 52 = "Guizhou" 53 = "Yunnan" 54 = "Tibet" 61 = "Shaanxi" 62 = "Gansu" 63 = "Qinghai" 64 = "Ningxia" 65 = "Xinjiang" 71 = "Taiwan" 81 = "Hong Kong" 82 = "Macau" 91 = "Foreign" Generate a non-repetitive number Sub Calcapiao () Dim strcaipiaonoarr () AS STRING DIM STRSQL AS STRING DIM STRCAIPIAONO AS STRING STRCAIPIAONO = "01, 02, 03, 04, 05, 06, 07, 08, 109, 10, 11, 12, 13, 14, 10, 11, 17, 18, 19, 20, 21, 22, 23, 24) 25, 26, 27, 28, 29, 30, 31, 32, 33 " DIM STRTEMPARR (7) AS STRING Dim Strzhongjiangarr (7) AS String STRCAIPIAONOARR = Split (strcaipiaono, ",") DIM INTRAND AS INTEGER DIM I as integer DIM J AS INTEGER i = 0 Dim Find As Boolean Do While True Find = false Randomize INTRAND = INT ((33 * RND) 1) For j = 0 to i - 1 IF straTemParr (j) = cstr (intrand) THEN Find = TRUE END IF NEXT IF not find kil StrtemParr (j) = CSTR (Intrand) Strzhongjiangarr (i) = CSTR (Intrand) 'Text1 (i) = Strzhongjiangarr (i) i = i 1 IF i = 7 THEN Exit do END IF END IF Loop End Sub