查询网格记录时收到错误

时间:2015-12-16 19:39:58

标签: sql razor datagrid webmatrix

我正在尝试选择表中属于该用户的所有记录。我想使用用户的登录ID。每次运行应用程序时都会收到此错误:

  

必须声明标量变量" @ 48"

以下是代码:

var UserId = WebSecurity.GetUserId(HttpContext.Current.User.Identity.Name);
var db = Database.Open("ApplicationServices");
var stQueryString = "SELECT * FROM Assessment WHERE (UserId) = (@48) ORDER BY SubmitDate";
var data = db.Query(selectQueryString, UserId);
var grid = new WebGrid(data);

 <form action="Screening.cshtml">
    <input type="submit" value="New Assessment">
 </form>
 <div id="grid">
          @grid.GetHtml(
                tableStyle: "grid",
                headerStyle: "grid-header",
                alternatingRowStyle: "grid-alternating-row",
                selectedRowStyle: "grid-selected-row",
                rowStyle: "grid-row-style",
                columns: grid.Columns(
                  grid.Column(header:"", format:@<a href="View/@item.Id">View</a>),
                  grid.Column("Name", format:@<text>item.ClientName</text>),
                  grid.Column("Date", format:@<text>item.SubmitDate</text>)))            
 </div>

0 个答案:

没有答案