2014年10月6日 星期一

設定網頁編碼



在做檔案複製的時候,發現中文檔名response出來變亂碼,調整網頁編碼utf-8時,中文檔名顯示正常,但iis給的中文錯誤訊息變亂碼。

因此設定網頁編碼

<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">

2014年8月27日 星期三

下拉式選單 Select


<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
    <td bgcolor="#CAF2FF" width="20%" class="font" align="center">匯入年份</td>
        <td bgcolor="#FFFFFF" width="80%" class="font" align="left">
        <Select Name='sel_year'>
            <option value="" selected>---請選擇---</option>
<%
        For i=year(date) to year(date)+1
%>
<Option Value="<%=i%>"><%=i%></Option>
            <%
Next
%></Select>
           
        </td>
</tr>

2014年8月18日 星期一

sql injection






<%
Response.ExpiresAbsolute = Now() - 1
Response.Buffer = True
Response.Expires = 0
Response.cacheControl="no cache"
Function FRequest(ByVal ChkStr) 

Dim Str 
Str = Trim(Request(ChkStr)) 

If IsNull(Str) Then 
FRequest = "" 
Exit Function 
End If 

Dim re 
Set re = new RegExp 
re.IgnoreCase = True 
re.Global = True 
re.Pattern = "(\r\n){3,}" 
Str = re.Replace(Str,"$1$1$1") 
Set re = Nothing 

Str = Replace(Str,"'","''") 
Str = Replace(Str, "--", "&#45;&#45;")    
Str = Replace(Str, "/*", "&#47;&#42;")    
Str = Replace(Str, "*/", "&#42;&#47;")    
Str = Replace(Str, "select", "sel&#101;ct") 
Str = Replace(Str, "join", "jo&#105;n") 
Str = Replace(Str, "union", "un&#105;on") 
Str = Replace(Str, "where", "wh&#101;re") 
Str = Replace(Str, "insert", "ins&#101;rt") 
Str = Replace(Str, "delete", "del&#101;te") 
Str = Replace(Str, "update", "up&#100;ate") 
Str = Replace(Str, "like", "lik&#101;") 
Str = Replace(Str, "drop", "dro&#112;") 
Str = Replace(Str, "create", "cr&#101;ate") 
Str = Replace(Str, "modify", "mod&#105;fy") 
Str = Replace(Str, "rename", "ren&#097;me") 
Str = Replace(Str, "alter", "alt&#101;r") 
Str = Replace(Str, "cast", "ca&#115;t") 
Str = Replace(Str, "ASPSESSIONIDCCDDTASQ", "") 
Str = Replace(Str, "ASPSESSIONIDCACATBSQ", "") 
FRequest = Str 

End Function
on error resume next
%>
<!-- #include file="../admin/setting/conn.asp"-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="zh-TW">
<head>




程式 : cat, pda ,timesheet01.asp

2014年8月14日 星期四

檔案複製 錯誤 '800a0046' 沒有使用權限





Set fs=Server.CreateObject("Scripting.FileSystemObject")
fs.CopyFile Src_fName,Des_fPath & "\"



Microsoft VBScript 執行階段錯誤 錯誤 '800a0046'

沒有使用權限

/admin/big5/fun/gen/trans.asp, 列53


使用 On filesystemobject的 .filecopy 方法,得到以下錯誤訊息,應該如何處理? 
Microsoft VBScript runtime error '800a0046' 
Permission denied 

答: 請確定最後的參數有包含一個反斜線(backslash) ,說明如下 
是 "c:\temp\" 
而不是 c:\temp" 

參考
http://big5.webasp.net/article/13/12027.htm




遇到另一個狀況,也是出現同樣的錯誤訊息。

狀況 : 有修改過windows使用者密碼

重開機之後就正常了。


檔案名稱太複雜也不允許,例:RR-ENR-2.1-en-TW.pdf 。





2014年7月26日 星期六

安裝網路印表機



網路上很多教學了

自己就當作紀錄




































完畢。

=========================================

2014年7月16日 星期三

搞定asp

搞定asp


這篇文章教你在一個小時裏如何搞定asp,非常實用,對於想學asp的同學可能有所幫助!!
一、語法
<1>語句
<%...........%>
<2>定義變數dim語句
<%
dim a,b
a=10
b=”ok!”
%>
注意:定義的變數可以是數值型,也可以是字元或者其他類型的
<3>簡單的控制流程語句
1. if 條件1 then
語句1
elseif 條件2 then
語句2
else
語句3
end if
2.while 條件
語句
wend
3.for count=1 to n step m
語句1
exit for
語句2
next
二.asp資料庫簡單*作教程
<1>.資料庫連接(用來單獨編制連接檔conn.asp)
<%
set conn = server.createobject(adodb.connection)
conn.open driver={microsoft access driver (*.mdb)}; dbq= & server.mappath(\bbs\db1\user.mdb)
%>
(用來連接bbs\db1\目錄下的user.mdb資料庫)
<2>顯示資料庫記錄
原理:將資料庫中的記錄一一顯示到用戶端流覽器,依次讀出資料庫中的每一條記錄
如果是從頭到尾:用迴圈並判斷指針是否到末 使用: not rs.eof
如果是從尾到頭:用迴圈並判斷指針是否到開始 使用:not rs.bof
 (包含conn.asp用來打開bbs\db1\目錄下的user.mdb資料庫)
<%
set rs=server.createobject(adodb.recordset) (建立recordset物件)
sqlstr=select * from message ---->(message為資料庫中的一個資料表,即你要顯示的資料所存放的資料表)
rs.open sqlstr,conn,1,3 ---->(表示打開資料庫的方式)
rs.movefirst ---->(將指標移到第一條記錄)
while not rs.eof ---->(判斷指針是否到末尾)
response.write(rs(name)) ---->(顯示資料表message中的name欄位)
rs.movenext ---->(將指標移動到下一條記錄)
wend ---->(迴圈結束)
rs.close
conn.close 這幾句是用來關閉資料庫
set rs=nothing
set conn=nothing
%>
其中response對象是<a rel="nofollow" target="_blank" href='http://school.enet.com.cn/eschool/includes/zhuanti/shuyu/info/1/02/1684.shtml' target='
>增加資料庫記錄
增加資料庫記錄用到rs.addnew,rs.update兩個函數
 (包含conn.asp用來打開bbs\db1\目錄下的user.mdb資料庫)
<%
set rs=server.createobject(adodb.recordset) (建立recordset物件)
sqlstr=select * from message ---->(message為資料庫中的一個資料表,即你要顯示的資料所存放的資料表)
rs.open sqlstr,conn,1,3 ---->(表示打開資料庫的方式)
rs.addnew 新增加一條記錄
rs(name)=xx 將xx的值傳給name欄位
rs.update 刷新資料庫
rs.close
conn.close 這幾句是用來關閉資料庫
set rs=nothing
set conn=nothing
%>
<4>刪除一條記錄
刪除資料庫記錄主要用到rs.delete,rs.update
 (包含conn.asp用來打開bbs\db1\目錄下的user.mdb資料庫)
<%
dim name
name=xx
set rs=server.createobject(adodb.recordset) (建立recordset物件)
sqlstr=select * from message ---->(message為資料庫中的一個資料表,即你要顯示的資料所存放的資料表)
rs.open sqlstr,conn,1,3 ---->(表示打開資料庫的方式)
while not rs.eof
if rs.(name)=name then
rs.delete
rs.update 查詢資料表中的name欄位的值是否等於變數name的值xx,如果符合就執行刪除,
else 否則繼續查詢,直到指針到末尾為止
rs.movenext
emd if
wend
rs.close
conn.close 這幾句是用來關閉資料庫
set rs=nothing
set conn=nothing
%>
<5>關於資料庫的查詢
(a) 查詢欄位為字元型
<%
dim user,pass,qq,mail,message
user=request.form(user)
pass=request.form(pass)
qq=request.form(qq)
mail=request.form(mail)
message=request.form(message)
if trim(user)&x=x or trim(pass)&x=x then (檢測user值和pass值是否為空,可以檢測到空格)
response.write(註冊資訊不能為空)
else
set rs=server.createobject(adodb.recordset)
sqlstr=select * from user where user='&user&' (查詢user資料表中的user欄位其中user欄位為字元型)
rs.open sqlstr,conn,1,3
if rs.eof then
rs.addnew
rs(user)=user
rs(pass)=pass
rs(qq)=qq
rs(mail)=mail
rs(message)=message
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write(註冊成功)
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write(註冊重名)
%>
(b)查詢欄位為數字型
<%
dim num
num=request.form(num)
set rs=server.createobject(adodb.recordset)
sqlstr=select * from message where id=&num (查詢message資料表中id欄位的值是否與num相等,其中id為數字型)
rs.open sqlstr,conn,1,3
if not rs.eof then
rs.delete
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write(刪除成功)
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write(刪除失敗)
%>
<6>幾個簡單的asp物件的講解
response物件:伺服器端向用戶端發送的資訊物件,包括直接發送資訊給流覽器,重新定向url,或設置cookie值
request對象:用戶端向伺服器提出的請求
session物件:作為一個總體變數,在整個站點都生效
server物件:提供對伺服器上方法和屬性的訪問
(a) response物件的一般使用方法
比如:
<%
resposne.write(hello, welcome to asp!)
%>
在用戶端流覽器就會看到 hello, welcome to asp! 這一段文字
<%
response.redirect(www.sohu.com)
%>
如果執行這一段,則流覽器就會自動連接到 “搜狐” 的網址
關於response物件的用法還有很多,大家可以研究研究
request物件的一般使用方法
比如用戶端向伺服器提出的請求就是通過request物件來傳遞的列如 :你在申請郵箱的所填寫的個人資訊就是通過該物件來將你所填寫的資訊傳遞給伺服器的
比如:這是一段表單的代碼,這是提供給客戶填寫資訊的,填寫完了按“提交”傳遞給request.asp檔處理後再存入伺服器資料庫
<form target="_blank" name="form1" method="post">
<p>
<input type="text" name="user">
</p>
<p>
<input type="text" name="pass">
</p>
<p>
<input type="submit" name="submit" value="提交">
</p>
</form>
那麼request.asp該如何將其中的資訊讀入,在寫入資料庫,在這裏就要用到
request物件了,下面我們就來分析request.asp的寫法
<%
dim name,password (定義user和password兩個變數)
name=request.form(“user”) (將表單中的user資訊傳給變數name)
password=request.form(“pass”) (將表單中的pass資訊傳給變數password)
%>
通過以上的幾句代碼我們就將表單中的資料讀進來了,接下來我們要做的就是將
資訊寫入資料庫了,寫入資料庫的方法上面都介紹了,這裏就不一一復述了。



原文出處:http://smilealin.pixnet.net/blog/post/27721174-%E6%90%9E%E5%AE%9Aasp