Archive

文章標籤 ‘asp’

ASP怎麼避免Insert資料時有空字串會出現錯誤

2010年1月14日 尚無評論

知識家有網友問 Here
怎麼避免Insert資料時有空字串會出現錯誤

只要加一個MM_IIf的Fuction就可以了

<%
name = replace(trim(request("name")),"'","''")
NEWS_PIC  = replace(trim(request("NEWS_PIC")),"'","''")

' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function

set rs = server.createobject("adodb.recordset")
sql = "INSERT INTO INDEX_NEWS(NEWS_PIC) VALUES('" & MM_IIF(NEWS_PIC, NEWS_PIC, null) & "')"
'response.write sql
'response.end
cnn.Execute(sql)
%>
Categories: 程式設計 Tags: ,

使用DreamWeaver一次新增多筆資料的方法

2010年1月10日 尚無評論

這是結合DW的插入紀錄語法
與重複區域的語法
二者結合改裝出來的
完全不用手動輸入程式
只需把DreamWeaver自動產生出來的程式
修修剪剪就成了
辦法是人想出來的

先在網頁上建立一個資料集
然後將該筆資料集加上重複區域

DW會在資料集的上下方加入While的語法
將資料集包住
如下:

<%
While ((ShowClassNameRep__numRows <> 0) AND (NOT ShowClassName.EOF))
%>
資料集...
<%
ShowClassNameRep__index=ShowClassNameRep__index+1
ShowClassNameRep__numRows=ShowClassNameRep__numRows-1
ShowClassName.MoveNext()
Wend
%>

閱讀全文...

Categories: 程式設計 Tags: ,