作者linus (羽調--奈勒斯)
看板C_Sharp
標題Re: [問題] ASP.NET
時間Fri May 13 16:13:22 2005
※ 引述《kikolee (kiko)》之銘言:
: : 嗯.........可是B在資料表的設計上是可填null
: : 所以沒有填資料應該視為null填入資料庫不是嗎??
: : 既然可接受null應該不會出錯才是....@@"
: 基本上SQL update的語法為:
: UPDATE table SET column_1 = express_1
: [,column_2 = express_2]
: ... [,column_i = express_i]
: 所以當只有left part 而沒有 right part時,這個語法就是錯的。
: 而且update時不填值,在SQL中不代表就是填入null值喔。
請問一下....在ASP.NET語法上, 要把傳遞給資料庫的值設定成null
要怎麼寫??
例:
<MM:Insert ID="EnglishInsert"
ConnectionString='<%# System.Configuration.ConfigurationSettings.
AppSettings("MM_CONNECTION_STRING_MultipleAuction") %>'
CommandText='<%# "INSERT INTO
English (ProductID,AnnouncePrice,ReservePrice,LimitPrice,ForestalledPrice)
VALUES (?,?,?,?,?)" %>'
CreateDataSet="false"
Debug="true"
Expression='false'
GetRecordCount="false"
IsStoredProcedure="false"
runat="server"
DatabaseType='<%# System.Configuration.ConfigurationSettings.
AppSettings("MM_CONNECTION_DATABASETYPE_MultipleAuction") %>'
>
<Parameters>
<Parameter Name="@ProductID" Value='<%# Session("MaxNowValue") %>'
Type="VarChar" />
<Parameter Name="@AnnouncePrice" Value='<%# IIf((Request.Form
("AnnouncePrice") <> Nothing), Request.Form("AnnouncePrice"), "0") %>'
Type="VarChar" />
<Parameter Name="@ReservePrice" Value='<%# IIf((Request.Form
("ReservePrice") <> Nothing), Request.Form("ReservePrice"), "0") %>'
Type="VarChar" />
<Parameter Name="@LimitPrice" Value='<%# IIf((Request.Form
("LimitPrice") <> Nothing), Request.Form("LimitPrice"), "0") %>'
Type="VarChar" />
<Parameter Name="@ForestalledPrice" Value='<%# IIf((trim(Request.Form
("ForestallPrices")) <> ""), trim(Request.Form("ForestallPrices")), "0") %>'
Type="VarChar" />
</Parameters>
</MM:Insert>
if trim(ForestallPrices.text)="" then
/*將傳至DB的ForestallPrices值設成null*/
Exit Function
CheckData=true
END IF
黃色部分該怎麼寫才對??
謝謝....Orz
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.163.197.102
推 tomex:DBNull.Value 211.78.132.15 05/13
推 linus:編譯器錯誤訊息: BC30311: 型別 System.DBNull 的218.163.197.102 05/13
→ linus:值無法轉換成 System.Web.UI.WebControls.TextBoxꄠ218.163.197.102 05/13
推 liunate:DBNull.Value? 203.73.225.241 05/13