我正在使用ASP.NET Razor。CSHTML - SQL QUERY .... WHERE NAME = @ NameOne
<form style="display:inline" name="formular1" method="post" action="default.cshtml">
<select name="phone1" class="dropdown">
@foreach(var row in db.Query("SELECT * FROM Handy")){
<option value="@row.Handyname">@row.Handyname</option>
}
</select>
vs.
<select name="phone2" class="dropdown">
@foreach(var row in db.Query("SELECT * FROM Handy")){
<option value="@row.Handyname">@row.Handyname</option>
}
</select>
<input type="submit"/ value="Compare">
</form>
@{
var phoneOne = "";
var phoneTwo = "";
if(IsPost){
// request input of the select forms
phoneOne = Request["phone1"];
phoneTwo = Request["phone2"];
}
}
</div>
<div class="content">
<div class="start">
<p><h2>@phoneOne</h2></p>
<ul>
@{
if(IsPost){
foreach(var row in db.Query("SELECT * FROM Handy WHERE [email protected]")){
<li>processor: @row.Prozessor GHz</li>
<li>memory: @row.RAM MB Ram</li>
<li>weight: @row.Gewicht g</li>
<li>display: @row.Display ''</li>
<li>OS: @row.OS</li>
}
}
}
</ul>
</div>
獲取查詢錯誤:WHERE Handyname = @ phoneOne ...把它們全部正常工作。我究竟做錯了什麼?
謝謝:)!
什麼是錯誤? SQL錯誤還是Razor? – GalacticCowboy