0
我有一個asp/razor網頁,我用它來填充鏡頭數據及其選項。如何獲取Null錯誤?
我想返回一個名爲SID的值(如果存在的話),如果不存在,則爲空。
我使用,如果statment要做到這一點,但瀏覽器報告錯誤:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'SID' does not exist in the current context
Source Error:
Line 238: <div class="row">
Line 239: <span class="label"><label for="salesid">SalesID:</label></span>
Line 240: <input type="text" name="salesid" id="salesid" [email protected] size="15" />
Line 241: </div>}
Line 242: else {@message;}
Source File: ~\DiscountCustomers.cshtml Line: 240
--------------------------------------------------------------------------------
@{
Layout = "~/_SiteLayout.cshtml";
var db = Database.Open("A-LensCatFE-01SQL") ;
var CustomerCode = UrlData[0];
var message = "";
// vars for dropdowns:
var ListSRP =db.Query("Select * FROM lstSRPBasedOn");
var LensName = db.Query("Select Form, ShortName FROM dbo.qryLAStyleMin ORDER BY Form");
// vars for modal forms insert data:
var query = ("Select * from dbo.qryCustomersAll Where CustomerCode= @0");
var data = db.QuerySingle(query, CustomerCode);
var emcid = data.CID;
var query1 = ("Select CatID from dbo.qryCustomersAll Where CustomerCode= @0");
var catid = db.QueryValue(query1, CustomerCode);
var query3 =("Select * from dbo.qryPromo2 Where [email protected]");
var data3 = db.QuerySingle(query3, CustomerCode);
if (data3 != null)
{var SID = data3.SalesID;}
else
{ message="Data not found";}
}
---------------------------------------------------------------
@if (data3 != null){
<div class="row">
<span class="label"><label for="salesid">SalesID:</label></span>
<input type="text" name="salesid" id="salesid" [email protected] size="15" />
</div>}
else {@message;}
---------------------------------------------------------------
我在做什麼錯?我怎麼能通過這個問題?謝謝。